Python: No module named sphinx error

2019-08-09 10:54发布

I have followed following guide.

$ pip install sphinx sphinx-autobuild
$ pip freeze | grep "sphinx"
sphinx-autobuild==0.6.0
sphinxcontrib-websupport==1.0.0

$ cd docs
$ sphinx-quickstart
$ make html

make html gives following error:

/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python: No module named sphinx
make: *** [help] Error 1

[Q] How could I prevent this error from happening?

Thank you for your valuable time and help.

2条回答
Rolldiameter
2楼-- · 2019-08-09 11:00

I had the same issue, and I thought it might be helpful to share the solution I found.

Open the Makefile file, and change the following line:

SPHINXBUILD = python -msphinx

To this one:

SPHINXBUILD = python3 -msphinx

查看更多
放荡不羁爱自由
3楼-- · 2019-08-09 11:16

First, don't install anything into your system's Python. Use either a virtual environment or your system's user installs to isolate packages from the system Python. The Python Packaging Authority provides an explanation of why virtual environments are a good idea™.

I prefer to start by installing another version of Python on my system, either using the official installers for macOS (beginner) or pyenv (not beginner). Install Python 3.x unless you absolutely must use Python 2.

Next install or upgrade your Python's packaging tools. This is one of the very rare times that I install or upgrade packages in my Pythons, although you may want to do so for your user.

Next create and use a virtual environment.

Finally follow the correct guide to install Sphinx into your virtual environment and get started using Sphinx.

查看更多
登录 后发表回答