无法导入扩展名... SphinxDirective

时间:2019-06-15 17:11:45

标签: python-sphinx

我正在尝试从https://sphinx.readthedocs.io/en/master/development/tutorials/todo.html#writing-the-extension来测试狮身人面像扩展名TODO。

但是,此“从docutils.parsers.rst导入SphinxDirective导入”无效,给出“扩展错误: 无法导入扩展名待办事项(例外:没有名为SphinxDirective的模块) “

我尝试了python2和python3,并阅读了文档环境。

代码在这里https://www.sphinx-doc.org/en/master/development/tutorials/todo.html#writing-the-extension

ReadTheDocs给出以下消息:

Running Sphinx v1.8.5
loading translations [en]... done

Traceback (most recent call last):
  File "/home/docs/checkouts/readthedocs.org/user_builds/demo-sphinx-extensions-for-dirac/envs/latest/lib/python3.7/site-packages/sphinx/registry.py", line 472, in load_extension
    mod = __import__(extname, None, None, ['setup'])
  File "/home/docs/checkouts/readthedocs.org/user_builds/demo-sphinx-extensions-for-dirac/checkouts/latest/docs/todo.py", line 6, in <module>
    from docutils.parsers.rst import SphinxDirective
ImportError: cannot import name 'SphinxDirective' from 'docutils.parsers.rst' (/home/docs/checkouts/readthedocs.org/user_builds/demo-sphinx-extensions-for-dirac/envs/latest/lib/python3.7/site-packages/docutils/parsers/rst/__init__.py)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/docs/checkouts/readthedocs.org/user_builds/demo-sphinx-extensions-for-dirac/envs/latest/lib/python3.7/site-packages/sphinx/cmd/build.py", line 303, in build_main
    args.tags, args.verbosity, args.jobs, args.keep_going)
  File "/home/docs/checkouts/readthedocs.org/user_builds/demo-sphinx-extensions-for-dirac/envs/latest/lib/python3.7/site-packages/sphinx/application.py", line 228, in __init__
    self.setup_extension(extension)
  File "/home/docs/checkouts/readthedocs.org/user_builds/demo-sphinx-extensions-for-dirac/envs/latest/lib/python3.7/site-packages/sphinx/application.py", line 449, in setup_extension
    self.registry.load_extension(self, extname)
  File "/home/docs/checkouts/readthedocs.org/user_builds/demo-sphinx-extensions-for-dirac/envs/latest/lib/python3.7/site-packages/sphinx/registry.py", line 475, in load_extension
    raise ExtensionError(__('Could not import extension %s') % extname, err)
sphinx.errors.ExtensionError: Could not import extension todo (exception: cannot import name 'SphinxDirective' from 'docutils.parsers.rst' (/home/docs/checkouts/readthedocs.org/user_builds/demo-sphinx-extensions-for-dirac/envs/latest/lib/python3.7/site-packages/docutils/parsers/rst/__init__.py))

Extension error:
Could not import extension todo (exception: cannot import name 'SphinxDirective' from 'docutils.parsers.rst' (/home/docs/checkouts/readthedocs.org/user_builds/demo-sphinx-extensions-for-dirac/envs/latest/lib/python3.7/site-packages/docutils/parsers/rst/__init__.py))

1 个答案:

答案 0 :(得分:0)

好吧

必须使用教程https://www.sphinx-doc.org/en/master/development/tutorials/todo.html中的正确文件以及所有已安装的软件包。

这是在ReadTheDocs门户上确保的,扩展构建良好。

PS:文件和链接为https://github.com/miroi/demo-sphinx-extensions-for-DIRAC