Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PyCharm: Cannot find Sphinx in selected interpreter

I am trying to create documentation using Sphinx in PyCharm and it does not work. I already tried using the terminal command make html and it seems to work just fine. When I try to run Sphinx task in PyCharm it raises this error:

Traceback (most recent call last):
  File "/Applications/PyCharm.app/Contents/helpers/rest_runners/sphinx_runner.py", line 5, in <module>
    from sphinx import cmdline
  File "/Users/wtekimam/PycharmProjects/doctor/myvenv/lib/python3.6/site-packages/sphinx/cmdline.py", line 24, in <module>
    from sphinx.application import Sphinx
  File "/Users/wtekimam/PycharmProjects/doctor/myvenv/lib/python3.6/site-packages/sphinx/application.py", line 33, in <module>
    from sphinx.environment import BuildEnvironment
  File "/Users/wtekimam/PycharmProjects/doctor/myvenv/lib/python3.6/site-packages/sphinx/environment/__init__.py", line 45, in <module>
    from sphinx.util.websupport import is_commentable
  File "/Users/wtekimam/PycharmProjects/doctor/myvenv/lib/python3.6/site-packages/sphinx/util/websupport.py", line 11, in <module>
    from sphinxcontrib.websupport.utils import is_commentable  # NOQA
  File "/Users/wtekimam/PycharmProjects/doctor/myvenv/lib/python3.6/site-packages/sphinxcontrib/websupport/__init__.py", line 13, in <module>
    __import__('pkg_resources').declare_namespace(__name__)
  File "<frozen importlib._bootstrap>", line 961, in _find_and_load
  File "<frozen importlib._bootstrap>", line 950, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 646, in _load_unlocked
  File "<frozen importlib._bootstrap>", line 616, in _load_backward_compatible
  File "/Users/wtekimam/PycharmProjects/doctor/myvenv/lib/python3.6/site-packages/setuptools-28.8.0-py3.6.egg/pkg_resources/__init__.py", line 3017, in <module>
  File "/Users/wtekimam/PycharmProjects/doctor/myvenv/lib/python3.6/site-packages/setuptools-28.8.0-py3.6.egg/pkg_resources/__init__.py", line 3003, in _call_aside
  File "/Users/wtekimam/PycharmProjects/doctor/myvenv/lib/python3.6/site-packages/setuptools-28.8.0-py3.6.egg/pkg_resources/__init__.py", line 3045, in _initialize_master_working_set
  File "/Users/wtekimam/PycharmProjects/doctor/myvenv/lib/python3.6/site-packages/setuptools-28.8.0-py3.6.egg/pkg_resources/__init__.py", line 2577, in activate
  File "/Users/wtekimam/PycharmProjects/doctor/myvenv/lib/python3.6/site-packages/setuptools-28.8.0-py3.6.egg/pkg_resources/__init__.py", line 2151, in declare_namespace
  File "/Users/wtekimam/PycharmProjects/doctor/myvenv/lib/python3.6/site-packages/setuptools-28.8.0-py3.6.egg/pkg_resources/__init__.py", line 2091, in _handle_ns
  File "/Users/wtekimam/PycharmProjects/doctor/myvenv/lib/python3.6/site-packages/setuptools-28.8.0-py3.6.egg/pkg_resources/__init__.py", line 2120, in _rebuild_mod_path
AttributeError: '_NamespacePath' object has no attribute 'sort'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Applications/PyCharm.app/Contents/helpers/rest_runners/sphinx_runner.py", line 7, in <module>
    raise NameError("Cannot find sphinx in selected interpreter.")
NameError: Cannot find sphinx in selected interpreter.

note: I use virtual environment and I already configure PyCharm to use the same virtual environment that I use to run make html in terminal

like image 401
William Tekimam Avatar asked May 24 '26 21:05

William Tekimam


1 Answers

There are two requirements:

  1. Install Sphinx into your project's interpreter.
  2. Create a run configuration for a Sphinx task with the appropriate settings as specified in PyCharm's documentation.

    Here's a typical configuration with screenshot.

    • Command: html
    • Input: path/to/reST/source/files
    • Output: path/to/reST/build/files
    • Python Interpreter: Project Default (or whatever you select)
    • Working directory: path/to/conf.py

Sphinx task run configuration

like image 61
Steve Piercy Avatar answered May 26 '26 11:05

Steve Piercy



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!