python包管理之Pip安裝及使用-1

 

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

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

Downloadbootstrap

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

INSTALLide

1. windows上執行以下命令:工具

1 python get-pip.py

2. 安裝的後的驗證:ui

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

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

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

[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包的全部文件

 

 pip查詢selenium包文件

相關文章
相關標籤/搜索