python包管理之Pip安裝及使用

來源:互聯網
上載者:User

標籤:pypy   檔案   環境變數   net   安裝   指定   目錄   rip   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 copypython get-pip.py --no-index --find-links=c:\downloads
View Code

3. Linux下的安裝

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

4. 升級Pip

#On Linux or OS Xpip 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安裝及使用

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.