简体   繁体   中英

Python: No module named sphinx error

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.

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM