使HTML在Windows 10中无法用于Sphinx文档

5
我正在尝试遵循有关如何将sphinx和Readthedocs设置为项目的教程。我曾经在实习期间使用过Ubuntu上的Sphinx,并且设置相当无缝。我刚刚在我的Anaconda Power Shell上启动了sphinx-quickstart。当我尝试运行make html时,出现以下错误:
(base) PS D:\code\RaspberryServer\docs> make html
make : The term 'make' is not recognized as the name of a cmdlet, function, script file, or operable program. Check
the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1
+ make html
+ ~~~~
    + CategoryInfo          : ObjectNotFound: (make:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException


Suggestion [3,General]: The command make was not found, but does exist in the current location. Windows PowerShell does not load commands from the current location by default. If you trust this command, instead type: ".\make". See "get-help about_Command_Precedence" for more details.

起初我以为是因为我从未安装过MinGW。但即使这样做后,我似乎仍无法解决问题,也不知道如何开始调查。我的Python安装完全基于Anaconda。


4
该指南假定您使用的是cmd.exe,但您现在处于PowerShell控制台中。请尝试运行.\make.bat html - Lex Li
1
谢谢,这解决了我的问题。你能解释一下使用它们的区别吗?据我理解,PowerShell通常具有更灵活的方法(并且更接近UNIX)。 - Guilherme Theis
2个回答

15
扩展上述评论。
sphinx生成的默认站点假定您在多个操作系统上使用“make html”来生成HTML页面。
这是通过以下典型假设实现的:
- 您使用安装了(GNU) make的macOS或Linux,因此“make html”执行在Makefile中定义的任务。 - 您使用的是Windows和命令提示符(cmd.exe),因此“make html”实际上调用make.bat。
然而,您正在启动PowerShell控制台(“PS D:”表示),因此无法使“make html”正常工作。 PowerShell不知道如何处理“make”,也不会自动调用“make.bat”。您需要调用“.\make.bat html”而不是“make html”。

3
浪费了很多时间才发现这个问题 - 我希望他们把这个放在第一页! - Yost777
3
事实上,我也觉得很奇怪,文档说明了如何创建目录(mkdir)和进入目录(cd),但却完全没有提供“make html”命令的执行方法。 - ZetDen
在Win10的MINGW64 BASH终端中,可以尝试使用./make.bat clean html命令。 - undefined

2
您可以尝试使用 sphinx-build。据我所知,它能完成工作,并不依赖于您使用的操作系统。 >

但这取决于您使用的操作系统以及Python的配置方式。在许多情况下,您无法在Windows的命令提示符或PowerShell控制台上运行sphinx-build,因为相关路径不在Windows PATH环境变量中。这与macOS / Linux不同,在这些操作系统中,Python通常预配置为在终端中可用。 - Lex Li

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接