The 'sphinx-build' command was not found.

52,878

Solution 1

I stumbled into that problem too when installed Sphinx using pip. The problem was solved using the installation way proposed by official documentation:

For Python 3:

$ apt-get install python3-sphinx

For Python 2:

$ apt-get install python-sphinx

Solution 2

For macOS Mojave:

$ brew install sphinx-doc

upon install brew will notify you to add it to your path, so add the following line to your ~/.bash_profile:

export PATH="/usr/local/opt/sphinx-doc/bin:$PATH"

after that you can run the sphinx-build command (you can verify this by for example checking the version)

$ sphinx-build --version
sphinx-build 2.0.1

Solution 3

We added the wrong directory to the path.

Wrong:

c:\programdata\chocolatey\lib\python3\tools\lib\site-packages

Right:

c:\programdata\chocolatey\lib\python3\tools\Scripts

Solution 4

For Windows:

Setting python path in make.bat fixed the problem for me:

set SPHINXBUILD="D:\Python3\Scripts\sphinx-build.exe"

Solution 5

An alternative way to invoke sphinx-build is to explicitly load Sphinx's build module.

For Sphinx v1.7+:

python -m sphinx.cmd.build

Here's an example for that I did with my documentation:

$ python3 -m sphinx.cmd.build -b html docs/ docs/build/
Running Sphinx v4.0.2
loading pickled environment... done
building [mo]: targets for 0 po files that are out of date
building [html]: targets for 0 source files that are out of date
updating environment: 0 added, 1 changed, 0 removed
reading sources... [100%] api                                                                      
looking for now-outdated files... none found
pickling environment... done
checking consistency... done
preparing documents... done
writing output... [100%] index                                                                     
generating indices... genindex done
writing additional pages... search done
copying static files... done
copying extra files... done
dumping search index in English (code: en)... done
dumping object inventory... done
build succeeded.

The HTML pages are in docs/build.

I got the idea of trying to load the module with this answer, originally for sphinx-quickstart.
Suprisingly, I succeeded.

Share:
52,878
Shaun Luttin
Author by

Shaun Luttin

My professional work focuses on designing, testing, implementing/securing, and deploying distributed services. I kind be "that guy" too. Ship it!

Updated on June 30, 2021

Comments

  • Shaun Luttin
    Shaun Luttin about 3 years

    This was our processes of installing Sphinx.

    > choco install python -y -f
    > pip install sphinx
    

    We know that sphinx installed because of the following output.

    > pip show sphinx
    ---
    Metadata-Version: 2.0
    Name: Sphinx
    Version: 1.4.3
    Summary: Python documentation generator
    Home-page: http://sphinx-doc.org/
    Author: Georg Brandl
    Author-email: [email protected]
    License: BSD
    Location: c:\programdata\chocolatey\lib\python3\tools\lib\site-packages
    

    We also added its install location to our PATH.

    c:\programdata\chocolatey\lib\python3\tools\lib\site-packages
    

    Even so, running sphinx-build does not work.

    'sphinx-build' is not recognized as an internal or external command,
    operable program or batch file.