readthedocs / readthedocs.org

The source code that powers readthedocs.org
https://readthedocs.org/
MIT License
8.04k stars 3.58k forks source link

Extension numpydoc - exception: cannot import name 'Directive' #4057

Closed prisae closed 6 years ago

prisae commented 6 years ago

Details

Expected Result

Build the docs when I commit a change to GitHub.

Actual Result

I had no issues at all until yesterday. It started to fail, but not always.

If it fails, it fails with the following error:

Extension error:
Could not import extension numpydoc (exception: cannot import name 'Directive')

The changes between these submits were minor, and should not affect the docs in any way.

Any idea on that? I have numpydoc fixed to version 0.6 in requirements.txt at the moment, as 0.7.0 broke my citations, and I haven't properly tried out the new 0.8.0 yet.

safwanrahman commented 6 years ago

Directive was removed from sphinix package from version 1.7

>>> from sphinx.util.compat import Directive
/private/tmp/flask-praetorian/venv/lib/python3.6/site-packages/sphinx/util/compat.py:40:

RemovedInSphinx17Warning: sphinx.util.compat.Directive is deprecated and will be removed in Sphinx 1.7, please use docutils' instead.
  RemovedInSphinx17Warning)

The package numpydoc is still using the old version of sphinix 1.6.x Recently we have updated sphinix to 1.7.x #4035.

safwanrahman commented 6 years ago

You can add sphinx==1.6.7 to your requirements.txt file and the issue must solve.

Feel free to Reopen the issue if it still exists!

prisae commented 6 years ago

Thanks a bunch, that did do the trick!

sovzzz commented 2 years ago

If I want to move old doc before 1.7 to new sphinx, what changes should be done?

prisae commented 2 years ago

If I want to move old doc before 1.7 to new sphinx, what changes should be done?

That is a very generic question, and as such very hard to answer. Particularly as Sphinx 1.7 was released 4 years ago, and many things (not just sphinx) changed in that period.

Could you provide us with some more information? What did you try? What did not work? Can you post any error messages? Is it related to this issue?

sovzzz commented 2 years ago

Just report the same mistake as this issue, when I process a doc written in 2020. Considering rst file has nothing to do with sphinx's version, maybe create a whole new doc and copy old rst files will work?

prisae commented 2 years ago

Have you updated numpydoc? The here reported issue should no longer be a problem if you use up-to-date versions of sphinx and of numpydoc. (If you do not use numpydoc then it is another issue altogether.)

sovzzz commented 2 years ago

Problem solved after replace from sphinx.util.compat import Directive with from docutils.parsers.rst import Directive in a custom extension attached by the doc package.