【Python】軟體管理工具--pip

楊奇龍發表於2016-02-08
    因為專案的原因我需要深入的學習python,後端程式依賴各種各種軟體包,比如MySQLdb,新手可能會有些不熟悉 如何快速安裝所需要的python 包。常用的python 包安裝和管理有 easy_install, setuptools, pip,distribute。
本文則介紹pip---“A tool for installing and managing Python packages.“
安裝pip
先要獲取指令碼 get-pip.py  

  1. wget https://bootstrap.pypa.io/get-pip.py
  2. python get-pip.py
注意: 
get-pip.py 會幫你安裝setuptools,如果你已經安裝了,則會執行升級命令:

  1. pip install -U setuptools
升級pip
  1. pip install -U pip
安裝python 包
  1. pip install SomePackage        # 不指定版本 則下載最新版本
  2. pip install SomePackage==1.0.4 # 下載指定版本
例如 下載安裝 MySQLdb
  1. root@rac3:~/scripts# >pip install MySQL-python
  2. Collecting MySQL-python
  3. /usr/local/lib/python2.7/site-packages/pip/_vendor/requests/packages/urllib3/util/ssl_.py:315: SNIMissingWarning: An HTTPS request has been made, but the SNI (Subject Name Indication) extension to TLS is not available on this platform. This may cause the server to present an incorrect TLS certificate, which can cause validation failures. For more information, see https://urllib3.readthedocs.org/en/latest/security.html#snimissingwarning.
  4.   SNIMissingWarning
  5. /usr/local/lib/python2.7/site-packages/pip/_vendor/requests/packages/urllib3/util/ssl_.py:120: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. For more information, see https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning.
  6.   InsecurePlatformWarning
  7.   Downloading MySQL-python-1.2.5.zip (108kB)
  8.     100% |████████████████████████████████| 110kB 354kB/s
  9. Building wheels for collected packages: MySQL-python
  10.   Running setup.py bdist_wheel for MySQL-python ... done
  11.   Stored in directory: /root/.cache/pip/wheels/8c/0d/11/d654cad764b92636ce047897dd2b9e1b0cd76c22f813c5851a
  12. Successfully built MySQL-python
  13. Installing collected packages: MySQL-python
  14. Successfully installed MySQL-python-1.2.5


來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/22664653/viewspace-1987323/,如需轉載,請註明出處,否則將追究法律責任。

相關文章