spyder: Sphinx >=1.7.0 breaks help on Windows with a working dir on a drive different from the Python install drive
I faced this error while I was coding (typing) in the editor:
after closing it, the Spyder continues to its normal operation, I did not see any after effect.
Windows 10 - Python 3.6.4. The Spyder 3.2.7 was installed using Anaconda

About this issue
- Original URL
- State: closed
- Created 9 years ago
- Comments: 23 (13 by maintainers)
This error message is fired in C:\Python27\Lib\site-packages\spyder\plugins\help.py when an exception in method
runof classSphinxThreadis handled by thetry: except:blocksThis handling prevents the full traceback been shown in Spyder’s Internal terminal If you deactivate the try-except, the traceback appears:
The problem explained
buildmethod of classSphinxc:\Python27\Lib\site-packages\sphinx\application.py circa line 343 Callspath.relpath(os.path.relpath, in Windows defined in c:\python27\lib\ntpath.py ) with a single argument, some temporary dir usually in C:\relpathuses second argument’s default ‘.’, the python current working dir, sayos.getcwd()relpathfires aValueErrorif called with paths from different drives. So if Spyder’s working dir (python current working dir) is not in drive C: , the exception is firedWhy once per session
This exception switches help display mode from richt text to plain text
plain text mode doesnt use Sphinx, so the problem dissapears unless you switch back to richt text mode.
SOLUTIONS
Being involved Sphinx, Spyder and ntpath.py, there are various options
Patch ntpath.py You could patch
relpathin c:\python27\lib\ntpath.py , but this could be dangerous, other scripts can expect this exception been fired and handle it their own way.Patch Sphinx (my choose) c:\Python27\Lib\site-packages\sphinx\application.py this way
from sphinx.application import Sphinxinsert thisWarning: Seems to override
relpathin all Spyder app modules, not only in sphinx.applicationI can confirm that all sphinx help is in fact broken (not showing the tutorial, etc. at all, and only showing plain text of docstrings for Sphinx 1.7.0+ on Windows under the above stated conditions. I can confirm Sphinx <= 1.6.6 is unaffected, so the location for now is to downgrade to that with
conda install sphinx=1.6.6from the Anaconda prompt (or just don’t use a working directory different from your Python/Anaconda install).Thanks @dalthviz! I figured it was no longer a problem since no one else commented here.
Closing then.
@dalthviz, please investigate this one to see if it’s still a problem.
Well there we go, which is why in my original followup, I asked
With that in hand, I was able to immediately reproduce it after switching my working directory (top right) to another drive, and then went to “Show tutorial” as you mentioned. Therefore, it seems likely the error has to do with use of a relative path (i.e. relative to the working dir) that attempts to access a location on another windows drive somewhere in the Sphinx call. From there, it shouldn’t be too difficult for someone to trace and fix. I appreciate your help!
@CAM-Gerlach
Aha, now it appeared again in the same session which I told you
it has not appeared so far,Now, it can be produced by the same process.
I don’t do anything different to create just this error. For the pattern, it appears after I run a code. if I don’t run a code it does not appear. The code is on Drive D and Anaconda is installed on Drive C as Windows. Everything including the code is identical before and after I upgraded the Sphinx.
Hmm, interesting. So it has happened over multiple previous sessions? Any pattern to that? Also, anything different in your current session—project location/working directory, files open, etc?
@VanitarNordic Thanks. Can you try downgrading to 1.6.6 (with
conda install sphinx=1.6.6and see if the error reoccurs? If not, can you try to locate the version that stops causing the problem? If you can’t find it, did you update anything else at the same time you updated Sphinx and first saw the problem?The environment information is nice, but probably (hopefully) not necessary. What I asked for was what was stated in the new issue template that was apparently deleted/not followed, specifically your Qt and PyQt versions (from Help > About) and main dependencies (From Help > Dependencies > Copy to clipboard).