From a2f85e9be2546dcb8a15a9ce84a4ee8b5655758a 2020-05-29 15:00:40 From: Matthias Bussonnier Date: 2020-05-29 15:00:40 Subject: [PATCH] Merge pull request #12342 from blakejgriffin/sphinximage Fixed bug on windows where relative image path has wrong slashes --- 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]