运行 狮身人面像时出现导入错误

ImportError when running Sphinx

当 运行 sphinx 为我的项目生成文档时,我得到以下异常。

我 运行 ubuntu_latest 架构 x64 Github 操作。当运行 make html 在我自己的机器上(最新版本Mac)我没有遇到任何问题...

我真的迷路了,所以我很感激任何帮助

Exception occurred:
 File "/home/runner/.local/lib/python3.8/site-packages/prompt_toolkit/filters/app.py",    line 6, in <module>
   from prompt_toolkit.application.current import get_app
   ImportError: cannot import name 'get_app' from partially initialized module 'prompt_toolkit.application.current' (most likely due to a circular import) (/home/runner/.local/lib/python3.8/site-packages/prompt_toolkit/application/current.py)
   The full traceback has been saved in /tmp/sphinx-err-grr15ev2.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.
   A bug report can be filed in the tracker at <https://github.com/sphinx-doc/sphinx/issues>. Thanks!
   make[3]: *** [docs/CMakeFiles/docs.dir/build.make:70: docs/CMakeFiles/docs] Error 2
   make[2]: *** [CMakeFiles/Makefile2:533: docs/CMakeFiles/docs.dir/all] Error 2
   make[1]: *** [CMakeFiles/Makefile2:540: docs/CMakeFiles/docs.dir/rule] Error 2
make: *** [Makefile:280: docs] Error 2

这些是我文档的 requirements.txt:

Sphinx>=3
sphinx_rtd_theme
sphinx-autodoc-typehints

GitPython
PyGithub
requests

ipykernel
ipywidgets
nbsphinx
recommonmark

这个问题显然是已知的,并且也已发布在 spatialaudio/nbsphinx#596 中。正如它所说,临时修复是降级 promt-toolkit 的版本,它必须低于 3.0.0.

您可以使用

明确降级

pip install -U "prompt-toolkit<3.0.0"

或者只需在 requirements.txt 中添加一条规则:prompt-toolkit<3.0.0。希望这个不兼容问题能尽快得到解决。