这是我们安装Sphinx的过程。
> choco install python -y -f
> pip install sphinx
我们知道由于以下输出而安装了sphinx。
> 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: georg@python.org
License: BSD
Location: c:\programdata\chocolatey\lib\python3\tools\lib\site-packages
我们还将其安装位置添加到PATH中。
c:\programdata\chocolatey\lib\python3\tools\lib\site-packages
即便如此,运行sphinx-build
也不起作用。
'sphinx-build' is not recognized as an internal or external command,
operable program or batch file.
答案 0 :(得分:7)
当使用pip
安装Sphinx时,我偶然发现了这个问题。问题是使用official documentation提出的安装方式解决的:
对于Python 3:
$ apt-get install python3-sphinx
对于Python 2:
$ apt-get install python-sphinx
答案 1 :(得分:3)
对于macOS Mojave:
$ brew install sphinx-doc
在安装brew时,它将通知您将其添加到您的路径,因此将以下行添加到您的〜/ .bash_profile中:
export PATH="/usr/local/opt/sphinx-doc/bin:$PATH"
之后,您可以运行sphinx-build命令 (您可以通过例如检查版本来验证这一点)
$ sphinx-build --version
sphinx-build 2.0.1
答案 2 :(得分:1)
我们在路径中添加了错误的目录。
错:
c:\programdata\chocolatey\lib\python3\tools\lib\site-packages
右:
c:\programdata\chocolatey\lib\python3\tools\Scripts
答案 3 :(得分:1)
对于Windows:
在make.bat
中设置python路径为我解决了这个问题:
set SPHINXBUILD="D:\Python3\Scripts\sphinx-build.exe"
答案 4 :(得分:1)
我通过从 pip
安装并重新启动终端解决了这个问题。
答案 5 :(得分:0)
对于Macports添加
export PATH="/opt/local/Library/Frameworks/Python.framework/Versions/3.7/bin:$PATH"
修复$ HOME / .bash_profile问题
答案 6 :(得分:0)
调用 sphinx-build 的另一种方法是显式加载 Sphinx 的构建模块。
对于 Sphinx v1.7+:
python -m sphinx.cmd.build
以下是我对文档所做的示例:
$ 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.
我有了尝试使用 this answer, originally for sphinx-quickstart
加载模块的想法。
令人惊讶的是,我成功了。