Issues

Issue #1353 resolved

AttributeError: 'module' object has no attribute 'DocTestParser'

Eugeny Rostovtsev
created an issue

When I build docs, I have:

Exception occurred:
  File "/usr/lib/python2.7/site-packages/sphinx/ext/doctest.py", line 113, in <module>
    parser = doctest.DocTestParser()
AttributeError: 'module' object has no attribute 'DocTestParser'
The full traceback has been saved in /usr/src/tmp/sphinx-err-ryEIXm.log, if you want to report the issue to the developers.
Please also report this if it was a user error, so that a better error message can be provided next time.
Either send bugs to the mailing list at <http://groups.google.com/group/sphinx-users/>,
or report them in the tracker at <http://bitbucket.org/birkenfeld/sphinx/issues/>. Thanks!

In directory with sources:

$ egrep -R DocTestParser ./
./sphinx/ext/doctest.py:parser = doctest.DocTestParser()

/usr/src/tmp/sphinx-err-ryEIXm.log in attachment

Comments (15)

  1. Georg Brandl repo owner

    Could you insert a

    print doctest.__file__
    

    in the /usr/lib/python2.7/site-packages/sphinx/ext/doctest.py before the offending line?

    (Alternately, start Sphinx with the -P option and do import sys; print sys.modules['doctest'].__file__ at the Pdb prompt.)

  2. Eugeny Rostovtsev reporter
    $ sphinx-build -P -E -a -b pickle -c /usr/src/RPM/BUILD/python-module-pygtk_git-2.24.1 -d doctrees /usr/src/RPM/BUILD/python-module-pygtk_git-2.24.1/docs/html pickle
    Running Sphinx v1.3a0
    /usr/lib/python2.7/site-packages/sphinx/ext/doctest.pyc
    Exception occurred while building, starting debugger:
    Traceback (most recent call last):
      File "/usr/lib/python2.7/site-packages/sphinx/cmdline.py", line 242, in main
        warningiserror, tags, verbosity, parallel)
      File "/usr/lib/python2.7/site-packages/sphinx/application.py", line 140, in __init__
        self._init_builder(buildername)
      File "/usr/lib/python2.7/site-packages/sphinx/application.py", line 200, in _init_builder
        __import__('sphinx.builders.' + mod, None, None, [cls]), cls)
      File "/usr/lib/python2.7/site-packages/sphinx/builders/html.py", line 45, in <module>
        from sphinx.highlighting import PygmentsBridge
      File "/usr/lib/python2.7/site-packages/sphinx/highlighting.py", line 24, in <module>
        from sphinx.ext import doctest
      File "/usr/lib/python2.7/site-packages/sphinx/ext/doctest.py", line 20, in <module>
        doctest = __import__('doctest')
      File "/usr/lib/python2.7/site-packages/sphinx/ext/doctest.py", line 114, in <module>
        parser = doctest.DocTestParser()
    AttributeError: 'module' object has no attribute 'DocTestParser'
    > /usr/lib/python2.7/site-packages/sphinx/ext/doctest.py(114)<module>()
    -> parser = doctest.DocTestParser()
    (Pdb) import sys
    (Pdb) print sys.modules['doctest'].__file__
    *** KeyError: 'doctest'
    (Pdb) print doctest.__file__
    /usr/lib/python2.7/site-packages/sphinx/ext/doctest.pyc
    (Pdb)
    
  3. Takayuki Shimizukawa

    The attached log indicates that "/usr/lib/python2.7/site-packages/sphinx/ext" was in sys.path.

    I think it's the cause. I suspect your sys.path include "sphinx/ext" path, but it's not needed.

  4. Takayuki Shimizukawa

    Please delete it. If you can't delete, please let me know:

    1. What values are displayed by pprint sys.path in the pdb mode? (especially does it include "sphinx/path"?)
    2. How did you install Sphinx? (invoke setup.py? use pip? with virtualenv?)
    3. Is SPHINXPATH environment variable exist?
    4. Does SPHINXPATH include "sphinx/ext" path?
  5. Eugeny Rostovtsev reporter

    1:

    (Pdb) print sys.path
    ['/usr/lib/python2.7/site-packages/sphinx/ext', '/usr/bin', '/usr/src/RPM/BUILD/python-module-pygtk_git-2.24.1', '/usr/lib64/python27.zip', '/usr/lib64/python2.7', '/usr/lib64/python2.7/plat-linux2', '/usr/lib64/python2.7/lib-tk', '/usr/lib64/python2.7/lib-old', '/usr/lib64/python2.7/lib-dynload', '/usr/lib64/python2.7/site-packages', '/usr/lib64/python2.7/site-packages/gtk-2.0', '/usr/lib/python2.7/site-packages']
    (Pdb)
    
    1. setup.py

    2. No.

  6. Georg Brandl repo owner

    I think Takayuki means PYTHONPATH, not SPHINXPATH.

    In any case, sphinx.ext should not be in sys.path, so this issue can be closed from the sphinx side.

  7. Log in to comment