diff --git a/IPython/sphinxext/ipython_directive.py b/IPython/sphinxext/ipython_directive.py index 0481624..3d5b376 100644 --- a/IPython/sphinxext/ipython_directive.py +++ b/IPython/sphinxext/ipython_directive.py @@ -419,8 +419,8 @@ class EmbeddedSphinxShell(object): # insert relative path to image file in source # as absolute path for Sphinx # sphinx expects a posix path, even on Windows - posix_path = pathlib.Path(savefig_dir,filename).as_posix() - outfile = '/' + os.path.relpath(posix_path, source_dir) + path = pathlib.Path(savefig_dir, filename) + outfile = '/' + path.relative_to(source_dir).as_posix() imagerows = ['.. image:: %s' % outfile]