
Question:
I have followed following <a href="https://docs.readthedocs.io/en/latest/getting_started.html" rel="nofollow">guide</a>.
$ 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
<strong>[Q]</strong> How could I prevent this error from happening?
Thank you for your valuable time and help.
Answer1: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 <a href="https://packaging.python.org/installing/#creating-virtual-environments" rel="nofollow">why virtual environments are a good idea™</a>.
I prefer to start by installing another version of Python on my system, either using the <a href="https://www.python.org/downloads/mac-osx/" rel="nofollow">official installers for macOS</a> (beginner) or <a href="https://github.com/pyenv/pyenv" rel="nofollow">pyenv</a> (not beginner). Install Python 3.x unless you absolutely must use Python 2.
Next <a href="https://packaging.python.org/installing/#requirements-for-installing-packages" rel="nofollow">install or upgrade your Python's packaging tools</a>. 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 <a href="https://packaging.python.org/installing/#creating-virtual-environments" rel="nofollow">create and use a virtual environment</a>.
Finally follow the <a href="http://www.sphinx-doc.org/en/stable/usage/installation.html" rel="nofollow">correct guide to install Sphinx</a> into your virtual environment and get started using Sphinx.
Answer2:I had the same issue, and I thought it might be helpful to share the solution I found.
Open the <strong>Makefile</strong> file, and change the following line:
SPHINXBUILD = python -msphinx
To this one:
SPHINXBUILD = python3 -msphinx