diff --git a/IPython/sphinxext/ipython_directive.py b/IPython/sphinxext/ipython_directive.py index 0481624c42c..ad1a1272385 100644 --- a/IPython/sphinxext/ipython_directive.py +++ b/IPython/sphinxext/ipython_directive.py @@ -420,7 +420,7 @@ def process_image(self, decorator): # 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) + outfile = '/' + pathlib.Path(os.path.relpath(posix_path, source_dir)).as_posix() imagerows = ['.. image:: %s' % outfile]