1. 程式人生 > >python包管理之Pip安裝及使用

python包管理之Pip安裝及使用

pip安裝 font text span htm 3.2 iss load file

Python有兩個著名的包管理工具easy_install.py和pip。在Python2.7的安裝包中,easy_install.py是默認安裝的,而pip需要我們手動安裝。

pip可以運行在Unix/Linux, OS X, and Windows平臺上,支持CPython versions 2.6, 2.7, 3.1, 3.2, 3.3, 3.4 and also pypy.

Download

  下載pip的安裝包get-pip.py,下載地址:https://pip.pypa.io/en/latest/installing.html#id7

INSTALL

1. windows上執行如下命令:

1 python get-pip.py

2. 安裝的後的驗證:

執行完成後,在python的安裝目錄下的Scripts子目錄下,可以看到pip.exe、pip2.7.exe、pip2.exe等,這就表示pip安裝成功了。

註意:要想能在命令行上直接運行pip程序,需要scripts這個目錄加入到環境變量PATH中。

pip安裝的時候還可以使用安裝選項進行安裝,比如指定get-pip.py所在的位置:

[python] view plain copy
python get-pip.py --no-index --find-links=c:\downloads
技術分享圖片
[python] view plain copy
python get
-pip.py --no-index --find-links=c:\downloads
View Code


3. Linux下的安裝

#On  Debian and Ubuntu:
sudo apt-get install python-pip   

#On Fedora
sudo yum install python-pip

4. 升級Pip

#On Linux or OS X
pip install -U pip 

#On Windows :
python -m pip install -U pip

USage

#Install a package from PyPI:
pip install SomePackage ##安裝特定版本的package,通過使用==, >=, <=, >, <來指定一個版本號。pip install ‘Markdown<2.0‘ pip install Markdown>2.0,<2.0.3
##果有requirement的話,直接就可以安裝所有的了。
pip install -r requirements.txt
##Uninstall a package:
pip uninstall SomePackage 

##Upgrade a package:
pip install --upgrade SomePackage 

##Show what files were installed:
pip show --files SomePackage

##List what packages are outdated:
pip list --outdated

##例如:列出列出selunium包的所有文件
pip show --files selenim 

執行結果是列出selunium包的所有文件執行結果是列出selunium包的所有文件

技術分享圖片

python包管理之Pip安裝及使用