centos6下從源碼安裝setuptools和pip


1. 下載setuptools及pip的源碼包
	setuptools與pip都是python的模塊
	setuptools源碼包: https://pypi.python.org/pypi/setuptools
	pip源碼包: https://pypi.python.org/pypi/pip#downloads
2. 安裝setuptools與pip
目前下載的版本是setuptools-12.0.5.tar.gz與pip-6.0.6.tar.gz
用tar命令解壓, 格式:tar -xzvf xxxx.tar.gz
先安裝setuptools, 進行setuptools的源碼根目錄下, 執行以下命令進行setuptools模塊的安裝:
[plain] view plain copy
 
  1. # python setup.py install  
安裝完setuptools后, 接着安裝pip, 進入pip的源碼包根目錄下, 執行以下命令進行安裝:
[html] view plain copy
 
  1. # python setup.py build  
  2. # python setup.py install  
安裝完pip后. 看看pip都安裝在哪里. 執行以下命令:
[plain] view plain copy
 
  1. # whereis pip  
然后再執行 # pip  命令並回車, 如果無法用pip命令, 則可通過創建pip軟鏈接, 執行以下命令:
[plain] view plain copy
 
  1. # ln -s /usr/local/bin/pip /usr/bin/pip  
好啦, 檢測pip命令是否正常:
[plain] view plain copy
 
  1. # pip  
  2.   
  3. Usage:     
  4.   pip <command> [options]  
  5.   
  6. Commands:  
  7.   install                     Install packages.  
  8.   uninstall                   Uninstall packages.  
  9.   freeze                      Output installed packages in requirements format.  
  10.   list                        List installed packages.  
  11.   show                        Show information about installed packages.  
  12.   search                      Search PyPI for packages.  
  13.   wheel                       Build wheels from your requirements.  
  14.   zip                         DEPRECATED. Zip individual packages.  
  15.   unzip                       DEPRECATED. Unzip individual packages.  
  16.   help                        Show help for commands.  
  17.   
  18. General Options:  
  19.   -h, --help                  Show help.  
  20.   --isolated                  Run pip in an isolated mode, ignoring  
  21.                               environment variables and user configuration.  
  22.   -v, --verbose               Give more output. Option is additive, and can be  
  23.                               used up to 3 times.  
  24.   -V, --version               Show version and exit.  
  25.   -q, --quiet                 Give less output.  
  26.   --log <path>                Path to a verbose appending log.  
  27.   --proxy <proxy>             Specify a proxy in the form  
  28.                               [user:passwd@]proxy.server:port.  
  29.   --retries <retries>         Maximum number of retries each connection should  
  30.                               attempt (default 5 times).  
  31.   --timeout <sec>             Set the socket timeout (default 15 seconds).  
  32.   --exists-action <action>    Default action when a path already exists:  
  33.                               (s)witch, (i)gnore, (w)ipe, (b)ackup.  
  34.   --trusted-host <hostname>   Mark this host as trusted, even though it does  
  35.                               not have valid or any HTTPS.  
  36.   --cert <path>               Path to alternate CA bundle.  
  37.   --client-cert <path>        Path to SSL client certificate, a single file  
  38.                               containing the private key and the certificate  
  39.                               in PEM format.  
  40.   --cache-dir <dir>           Store the cache data in <dir>.  
  41.   --no-cache-dir              Disable the cache.  
  42.   --disable-pip-version-check  
  43.                               Don't periodically check PyPI to determine  
  44.                               whether a new version of pip is available for  
  45.                               download. Implied with --no-index.  
如果不創建軟鏈接, 也可以直接使用pip的路徑來執行命令也是可以的, 如下:
[plain] view plain copy
 
  1. # /usr/local/bin/pip  
  2.   
  3. Usage:     
  4.   pip <command> [options]  
  5.   
  6. Commands:  
  7.   install                     Install packages.  
  8.   uninstall                   Uninstall packages.  
  9.   freeze                      Output installed packages in requirements format.  
  10.   list                        List installed packages.  
  11.   show                        Show information about installed packages.  
  12.   search                      Search PyPI for packages.  
  13.   wheel                       Build wheels from your requirements.  
  14.   zip                         DEPRECATED. Zip individual packages.  
  15.   unzip                       DEPRECATED. Unzip individual packages.  
  16.   help                        Show help for commands.  
  17.   
  18. General Options:  
  19.   -h, --help                  Show help.  
  20.   --isolated                  Run pip in an isolated mode, ignoring  
  21.                               environment variables and user configuration.  
  22.   -v, --verbose               Give more output. Option is additive, and can be  
  23.                               used up to 3 times.  
  24.   -V, --version               Show version and exit.  
  25.   -q, --quiet                 Give less output.  
  26.   --log <path>                Path to a verbose appending log.  
  27.   --proxy <proxy>             Specify a proxy in the form  
  28.                               [user:passwd@]proxy.server:port.  
  29.   --retries <retries>         Maximum number of retries each connection should  
  30.                               attempt (default 5 times).  
  31.   --timeout <sec>             Set the socket timeout (default 15 seconds).  
  32.   --exists-action <action>    Default action when a path already exists:  
  33.                               (s)witch, (i)gnore, (w)ipe, (b)ackup.  
  34.   --trusted-host <hostname>   Mark this host as trusted, even though it does  
  35.                               not have valid or any HTTPS.  
  36.   --cert <path>               Path to alternate CA bundle.  
  37.   --client-cert <path>        Path to SSL client certificate, a single file  
  38.                               containing the private key and the certificate  
  39.                               in PEM format.  
  40.   --cache-dir <dir>           Store the cache data in <dir>.  
  41.   --no-cache-dir              Disable the cache.  
  42.   --disable-pip-version-check  
  43.                               Don't periodically check PyPI to determine  
  44.                               whether a new version of pip is available for  
  45.                               download. Implied with --no-index.  
如果運氣不好, 出現如下信息:
[plain] view plain copy
 
  1. ImportError: No module named 'pip._vendor.requests'  
這是因為openssl模塊沒安裝好, 可執行以下命令來安裝:
[plain] view plain copy
 
  1. # yum install openssl-devel  
  
  
OK, Enjoy it!!!


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM