My Title

Sphinx 文档工具 配置详解

Ubuntu

Ubuntu安装非常简单,只需要输入以下命令即可:

sudo apt-get install python-sphinx

 

Windows

在Windows下安装Sphinx比较复杂一些。

  1. 安装Python
    Python官网 上下载合适版本的Python, 这里采用Python-2.7。
    为后续步骤方便,假定安装目录为 
    C:\Python27
    
  2. 安装Setuptools或Distribute
    Setuptools主要的用途是下载、安装、构建、删除Python,比较类似于Ubunto的apt-get,从这里 下载与Python相对应的Setuptools。
    但是Setuptools没有64位版本的。如果在64位win7上安装64位Python和32位setuptools,setuptools无法安装成功。解决的方案可以参考最下面的参考链接。
    这里我们采用一种替代工具:Distribute,该工具的下载地址为一个提供非官方Python lib的网站 ,请打开连接并搜索"Setuptools downloads"字符串,找到后会有Setuptools列表,我们选用的是setuptools- 1.1.5.win-amd64-py2.7.exe。
    Setuptools和Distribute都会安装在以下目录:
    C:\Python27\Scripts
    
  3. 设置环境变量
    在Windows中设置如下环境变量:
    PYTHON_HOME         C:\Python27
    PATH                …;%PYTHON_HOME%;%PYTHON_HOME%\Scripts;
    
  4. 安装Sphinx及dependency
    安装之前需要在CMD中设置HTTP代理:
C:\Users\28850586\test>set http_proxy=http://288xxxxx:******@proxy.cnbj.********.net:8080
C:\Users\28850586\test>set https_proxy=http://288xxxxx:******@proxy.cnbj.********.net:8080

(注意,此处是288xxxxx是员工工号,******是员工密码)
查看环境变量是否设置成功:

C:\Users\28850586\test>echo %http_proxy%   


接下来就可以正式安装了:

C:\Users\28850586\test>python --version     
Python 2.7.1 
C:\Users\28850586\test>easy_install sphinx 
C:\Users\28850586\test>easy_install blockdiag 
C:\Users\28850586\test>easy_install sphinxcontrib-blockdiag 
C:\Users\28850586\test>easy_install seqdiag 
C:\Users\28850586\test>easy_install sphinxcontrib-seqdiag 
C:\Users\28850586\test>easy_install actdiag 
C:\Users\28850586\test>easy_install sphinxcontrib-actdiag 
C:\Users\28850586\test>easy_install nwdiag 
C:\Users\28850586\test>easy_install sphinxcontrib-nwdiag 


参考链接:
Step-by-Step on Windows
Problem of installing setuptools on Win-64
Python Extention for Windows
posted @ 2014-03-07 13:22  Jared.Nie  阅读(1269)  评论(2编辑  收藏  举报
IP查询