在 Windows 上安装 python/sphinx 环境?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/8435703/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Installing a python/sphinx environment on windows?
提问by kdt
We use Sphinxfor documentation within our Linux/OSX python environment, but we have someone on Windows who would like to be able to get an environment in which they can edit and build the Sphinx documentation.
我们在 Linux/OSX python 环境中使用Sphinx作为文档,但我们在 Windows 上有人希望能够获得一个环境,他们可以在其中编辑和构建 Sphinx 文档。
Is it possible to set up Sphinx on windows? I'm guessing the hard part is installing a python environment and all the dependencies, but I have 0 experience with python on windows so somebody might be able to point me to a straightforward way to proceed.
是否可以在 Windows 上设置 Sphinx?我猜最难的部分是安装 python 环境和所有依赖项,但我在 windows 上使用 python 的经验为 0,所以有人可能会指出我一个简单的方法来继续。
回答by Krishna
For installing python on windows download Python. Run the executable and you are all set.
要在 Windows 上安装 python,请下载Python。运行可执行文件,一切就绪。
If you have pipinstalled then you can open command prompt and just type
如果您安装了pip,那么您可以打开命令提示符并输入
pip install -U Sphinx
If you don't have pipinstalled then you first need to install it by using the following at the command prompt
如果您没有安装pip,那么您首先需要在命令提示符下使用以下命令进行安装
python -m pip install -U pip
回答by RichardB
By far the simplest way to use Python on Windows is WinPython, which is a portable distribution that is as simple to use as any other portable app. It'll give you an icon for a WinPython command prompt from which you can use pip, etc., as if on any other (e.g. linux) system, or you can download packages and install them using WinPython's control panel.
到目前为止,在 Windows 上使用 Python 的最简单方法是WinPython,它是一个便携式发行版,与任何其他便携式应用程序一样易于使用。它将为您提供一个 WinPython 命令提示符图标,您可以从中使用 pip 等,就像在任何其他(例如 linux)系统上一样,或者您可以下载软件包并使用 WinPython 的控制面板安装它们。
回答by Cole
You can use pip-winnow to set up sphinx in a virtualenv on windows easily.
您现在可以使用pip-win在 windows 上的 virtualenv 中轻松设置 sphinx。
First, download and install Python. If you want to use the latexpdf builder you will also need to install either TeX Liveor MiKTeXfor windows.
首先,下载并安装Python。如果您想使用 latexpdf 构建器,您还需要为 Windows安装TeX Live或MiKTeX。
Next, run the pip-win.exe. It will automatically pull the required setuptools required and install pip and virtualenv on your system. When loaded it will pull up the Python you just installed, but if you installed it in a location other than default directory you can easily enter the absolute path or browse for it.
接下来,运行 pip-win.exe。它会自动拉取所需的安装工具并在您的系统上安装 pip 和 virtualenv。加载后,它会拉出您刚刚安装的 Python,但如果您将其安装在默认目录以外的位置,您可以轻松输入绝对路径或浏览它。
Next, in the Command: line you can create a new virtualenv by inputing:
接下来,在 Command: 行中,您可以通过输入以下内容来创建一个新的 virtualenv:
venv -c C:\foo\sphinx-venv
This will open a command prompt with you inside your virtualenv. Following this you can install sphinx with the pip command:
这将在您的 virtualenv 中打开一个命令提示符。在此之后,您可以使用 pip 命令安装 sphinx:
<sphinx-venv> C:\foo\> pip install sphinx
Now sphinx is installed on your windows machine in a virtual enviroment. You can use deactivate to escape your new environment.
现在 sphinx 安装在您的 Windows 机器上的虚拟环境中。您可以使用停用来退出新环境。
When ever you wish to enter your virtualenv again to build more sphinx projects you can either open pip-win and run:
当您希望再次进入您的 virtualenv 以构建更多 sphinx 项目时,您可以打开 pip-win 并运行:
venv C:\foo\sphinx-venv
Or you can create a custom python file to activate your sphinx environment and build your sphinx file such as:
或者您可以创建一个自定义 python 文件来激活您的 sphinx 环境并构建您的 sphinx 文件,例如:
import os
os.system("cmd /c \"CALL C:\foo\sphinx-venv\Scripts\activate.bat && make html\"")