简体   繁体   English

在Windows上安装python / sphinx环境?

[英]Installing a python/sphinx environment on windows?

We use Sphinx for 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? 是否可以在Windows上设置Sphinx? 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. 我猜测困难的部分是安装python环境和所有依赖项,但我在Windows上有0次python经验,所以有人可能能够指出我一种直接的方式继续。

For installing python on windows download Python . 在Windows上安装python下载Python Run the executable and you are all set. 运行可执行文件,你就完成了。

If you have pip installed then you can open command prompt and just type 如果您安装了pip,则可以打开命令提示符并输入

pip install -U Sphinx

If you don't have pip installed then you first need to install it by using the following at the command prompt 如果您没有安装pip,那么首先需要在命令提示符下使用以下命令来安装它

python -m pip install -U pip

You can use pip-win now to set up sphinx in a virtualenv on windows easily. 你现在可以使用pip-win轻松地在windows上的virtualenv中设置sphinx。

First, download and install Python . 首先,下载并安装Python If you want to use the latexpdf builder you will also need to install either TeX Live or MiKTeX for windows. 如果要使用latexpdf构建器,还需要安装TeX LiveMiKTeX for Windows。

Next, run the pip-win.exe. 接下来,运行pip-win.exe。 It will automatically pull the required setuptools required and install pip and virtualenv on your system. 它会自动拉出所需的setuptools,并在你的系统上安装pip和virtualenv。 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. 加载后它会拉出你刚刚安装的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. 这将在你的virtualenv中打开一个命令提示符。 Following this you can install sphinx with the pip command: 在此之后,您可以使用pip命令安装sphinx:

<sphinx-venv> C:\foo\> pip install sphinx

Now sphinx is installed on your windows machine in a virtual enviroment. 现在,sphinx在虚拟环境中安装在Windows机器上。 You can use deactivate to escape your new environment. 您可以使用停用来逃避新环境。

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\"")

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. 到目前为止,在Windows上使用Python的最简单方法是WinPython ,它是一种便携式发行版,与任何其他便携式应用一样简单易用。 It'll give you an icon for a WinPython command prompt from which you can use pip, etc., as if on any other (eg linux) system, or you can download packages and install them using WinPython's control panel. 它将为您提供WinPython命令提示符的图标,您可以从中使用pip等,就像在任何其他(例如Linux)系统上一样,或者您可以使用WinPython的控制面板下载软件包并安装它们。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM