【问题标题】:Run python module commands on Windows在 Windows 上运行 python 模块命令
【发布时间】:2021-07-17 05:23:18
【问题描述】:

我在 Windows 终端中使用 pip install sphinx 命令安装了 Sphinx,我想运行 sphinx-quickstart 在我的 docs 目录中创建文档,但它不起作用。

我得到了这个错误:

sphinx-quickstart : The term 'sphinx-quickstart' 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.

如果我尝试通过 GitBash 或在开头使用 pypython 运行它:

\path_to_python\python.exe: can't open file '\My_working_directory\docs\sphinx-quickstart': [Errno 2] No such file or directory 

我该如何解决这个问题?

【问题讨论】:

  • 发生这种情况的原因是因为 Sphinx 应该安装在您的虚拟环境中,并且您必须在使用它的终端上activate the virtual env。之后,无论您在何处运行,终端都会找到sphinx-quickstart 工具。如果您想查看它的位置,请参阅说明in this post
  • python_installation_folder\Scripts 在你的 PATH 中吗?
  • 我按照说明创建了目录。我启动了.bat 文件,现在终端一开始就有(tutorial-env),这很好。但是,如果我尝试在我的目录中调用 sphinx-quickstart,它会告诉我:'sphinx-quickstart' 不被识别为内部或外部命令、可运行程序或批处理文件。
  • 油,是的
  • 好吧,我不知道为什么Sphinx没有出现在python安装文件夹的Scripts目录中,我需要在虚拟环境中重新安装。

标签: python python-3.x python-sphinx windows-terminal


【解决方案1】:

最简单的方法是创建简单的虚拟环境,您将能够安装所需的软件包并运行它。

只需创建文件夹并运行命令来创建虚拟环境,然后使用.bat 文件激活它。

阅读docs,但它在 Python 的未来版本中可能会有所不同。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2023-03-23
    • 1970-01-01
    • 2018-04-07
    • 1970-01-01
    • 1970-01-01
    • 2011-06-02
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多