question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Sphinx >=1.7.0 breaks help on Windows with a working dir on a drive different from the Python install drive

See original GitHub issue

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

2018-02-28_11-48-56

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:23 (13 by maintainers)

github_iconTop GitHub Comments

3reactions
RicardoNogueralescommented, Mar 2, 2018

This error message is fired in C:\Python27\Lib\site-packages\spyder\plugins\help.py when an exception in method run of class SphinxThread is handled by the try: except: blocks

This handling prevents the full traceback been shown in Spyder’s Internal terminal If you deactivate the try-except, the traceback appears:

>>> Traceback (most recent call last):
  File "c:\python27\lib\site-packages\spyder\plugins\help.py", line 301, in run
    html_text = sphinxify(doc['docstring'], context)
  File "c:\python27\lib\site-packages\spyder\utils\help\sphinxify.py", line 215, in sphinxify
    sphinx_app.build(None, [rst_name])
  File "c:\python27\lib\site-packages\sphinx\application.py", line 344, in build
    'outdir': path.relpath(self.outdir),
  File "c:\python27\lib\ntpath.py", line 528, in relpath
    % (path_prefix, start_prefix))
ValueError: path is on drive c:, start on drive E:     

The problem explained

  • Help section rendering uses Sphinx to convert rst text help to nice HTML.Sphinx logs this activity.
  • Part of this logging is in build method of class Sphinx c:\Python27\Lib\site-packages\sphinx\application.py circa line 343
                  logger.info(self.builder.epilog % {
                      'outdir': path.relpath(self.outdir),
                      'project': self.config.project
                  })
    
    Calls path.relpath ( os.path.relpath, in Windows defined in c:\python27\lib\ntpath.py ) with a single argument, some temporary dir usually in C:\
  • Being called with a single argument, relpath uses second argument’s default ‘.’, the python current working dir, say os.getcwd()
  • relpath fires a ValueError if called with paths from different drives. So if Spyder’s working dir (python current working dir) is not in drive C: , the exception is fired

Why 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 relpath in 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

###                logger.info(self.builder.epilog % {
###                    'outdir': path.relpath(self.outdir),
###                    'project': self.config.project
###                })
                # PATCH----------------------------------------------
                try:
                    the_relpath = path.relpath(self.outdir)
                except ValueError:
                    the_relpath = self.outdir
                logger.info(self.builder.epilog % {
                    'outdir': the_relpath,
                    'project': self.config.project
                })
                # PACH----------------------------------------------
  • Override relpath in Spyder In C:\Python27\Lib\site-packages\spyder\utils\help\sphinxify.py after line 32 , from sphinx.application import Sphinx insert this
#-----------------------------------------------------------#PATCH
real_osp_relpath = osp.relpath
def relpath_patched(path, start='.'):
    try:
        #print '**** relpath_patched OK ****',path
        return real_osp_relpath(path, start)
    except:
        #print '**** relpath_patched avoided exception ****',path
        return path
sphinx.application.os.path.relpath = relpath_patched
# or os.path.relpath = relpath_patched
#-----------------------------------------------------------#PATCH

Warning: Seems to override relpath in all Spyder app modules, not only in sphinx.application

3reactions
CAM-Gerlachcommented, Mar 2, 2018

I 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.6 from the Anaconda prompt (or just don’t use a working directory different from your Python/Anaconda install).

Read more comments on GitHub >

github_iconTop Results From Across the Web

Windows Sphinx installation failed... what went wrong?
I'm following the instructions in Installing Sphinx - Windows. Python 2.7 has priority in my system path, but Python 3.8 is on my...
Read more >
Documentation » Installing Sphinx
Installation from PyPI​​ On Linux or MacOS, you should open your terminal and run the following command. On Windows, you should open Command...
Read more >
Sphinx Documentation - Read the Docs
Most Windows users do not have Python installed by default, so we begin with the installation of Python itself. If you are unsure, ......
Read more >
Considerations in adopting RHEL 8 Red Hat Enterprise Linux 8
Red Hat Enterprise Linux 8 supports installing from a repository on a local hard drive. Previously, the only installation method from a hard...
Read more >
Changelog - pip documentation v22.3.1
Deprecate --install-options which forces pip to use the deprecated install ... slash from a file:// URL built from an path with the Windows...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found