简体   繁体   English

找不到“sphinx-build”命令。

[英]The 'sphinx-build' command was not found.

This was our processes of installing Sphinx.这是我们安装 Sphinx 的过程。

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

We know that sphinx installed because of the following output.由于以下输出,我们知道安装了 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

We also added its install location to our PATH.我们还将其安装位置添加到我们的 PATH。

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

Even so, running sphinx-build does not work.即便如此,运行sphinx-build也不起作用。

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

I stumbled into that problem too when installed Sphinx using pip .使用pip安装 Sphinx 时,我也偶然发现了这个问题。 The problem was solved using the installation way proposed by official documentation :使用官方文档提出的安装方式解决了问题:

For Python 3:对于 Python 3:

$ apt-get install python3-sphinx

For Python 2:对于 Python 2:

$ apt-get install python-sphinx

For macOS Mojave:对于 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:安装 brew 时会通知您将其添加到您的路径中,因此将以下行添加到您的 ~/.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 命令(您可以通过例如检查版本来验证这一点)

$ sphinx-build --version
sphinx-build 2.0.1

For Windows:对于 Windows:

Setting python path in make.bat fixed the problem for me:make.bat设置 python 路径为我解决了这个问题:

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

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

我通过从pip安装并重新启动终端来解决这个问题。

For macports adding对于 macports 添加

export PATH="/opt/local/Library/Frameworks/Python.framework/Versions/3.7/bin:$PATH"

to $HOME/.bash_profile fixed the issue到 $HOME/.bash_profile 修复了这个问题

An alternative way to invoke sphinx-build is to explicitly load Sphinx's build module.调用 sphinx-build 的另一种方法是显式加载 Sphinx 的构建模块。

For Sphinx v1.7+:对于 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 .我想尝试用这个答案加载模块,最初是为了sphinx-quickstart
Suprisingly, I succeeded.令人惊讶的是,我成功了。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 用brew降级到python 3.6.5:错误/ bin / sh:sphinx-build:找不到命令make:*** [build]错误127 - Downgrade to python 3.6.5 with brew: Error /bin/sh: sphinx-build: command not found make: *** [build] Error 127 在 gitlab ci 管道/python 3 高山图像中找不到 sphinx-build 命令 - sphinx-build command not found in gitlab ci pipeline / python 3 alpine image Sphinx-build无法识别为内部或外部命令 - Sphinx-build can not be recognized as internl or external command Sphinx 的 OS X 安装:找不到“sphinx-build”和“sphinx-quickstart” - OS X install of Sphinx: The 'sphinx-build' and 'sphinx-quickstart' not found 更改 sphinx-build 主文件 - Change sphinx-build master file sphinx-build 失败 - autodoc 无法导入/查找模块 - sphinx-build fail - autodoc can't import/find module python的sphinx-build重新格式化rst文件 - python's sphinx-build reformats rst files sphinx-build:错误:无法识别的参数:-b html build / doctrees源build / html - sphinx-build: error: unrecognized arguments: -b html build/doctrees source build/html 在导入python模块时,Sphinx-build为SWIG生成的python文件生成错误 - Sphinx-build generates error for SWIG generated python file while importing the python module AttributeError: 'Values' 对象在运行 sphinx-build 时没有属性 'tab_width' - AttributeError: 'Values' object has no attribute 'tab_width' when running sphinx-build
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM