Search code examples
pythonpython-3.xpython-sphinximporterror

ImportError when running Sphinx


I get the following exception when running sphinx to generate the documentation for my project.

I am running on the ubuntu_latest architecture x64 on Github Actions. When running make html on my own machine (latest version of Mac) I do not encounter any problems...

I am really lost here, so I would appreciate any help

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

And these are the requirements.txt of my docs:

Sphinx>=3
sphinx_rtd_theme
sphinx-autodoc-typehints

GitPython
PyGithub
requests

ipykernel
ipywidgets
nbsphinx
recommonmark

Solution

  • This issue apparently is known and has also been posted in spatialaudio/nbsphinx#596. As it says, a temporary fix is to downgrade the version of promt-toolkit which must be lower than 3.0.0.

    You can explicitly downgrade with

    pip install -U "prompt-toolkit<3.0.0"

    Or simply add a rule in your requirements.txt: prompt-toolkit<3.0.0. Hopefully this incompatibility issue will be addressed soon.