centos系統下pip安裝使用詳解

來源:互聯網
上載者:User

標籤:pip安裝

pip類似RedHat裡面的yum,安裝Python包非常方便。本節詳細介紹pip的安裝、以及使用方法。

一、pip下載安裝

1.1 pip下載

wget "https://pypi.python.org/packages/source/p/pip/pip-1.5.4.tar.gz#md5=834b2904f92d46aaa333267fb1c922bb" --no-check-certificate


1.2 pip安裝    

# tar -xzvf pip-1.5.4.tar.gz

# cd pip-1.5.4

# python setup.py install


1.3 如果pip安裝後提示依然沒有pip命令,需在在添加環境變數

# vim /etc/profile

在文檔最後,添加:

export PATH="/usr/local/python2.7/bin:$PATH"

儲存,退出

然後運行:

#source /etc/profile


二、查看pip版本

pip -V

pip 1.5.4 from /usr/local/python2.7/lib/python2.7/site-packages/pip-1.5.4-py2.7.egg (python 2.7)


三、pip使用詳解

3.1 pip安裝包

pip install paramiko

  [...]

  Successfully installed paramiko


3.2 pip查看已安裝的包

[[email protected]]# pip show --files paramiko

---

Name: paramiko

Version: 1.16.0

Location: /usr/local/python2.7/lib/python2.7/site-packages

Requires: pycrypto, ecdsa

Files:

Cannot locate installed-files.txt


3.3 pip檢查哪些包需要更新

[[email protected] /]# pip list --outdated

setuptools (Current: 0.6c11 Latest: 19.2)

pip (Current: 1.5.4 Latest: 7.1.2)

Django (Current: 1.8.5 Latest: 1.9.1)


3.4 pip升級包

pip install --upgrade Django


3.5 pip卸載包

pip uninstall Django


四、常見錯誤

4.1 ImportError No module named setuptools解決辦法

wget http://pypi.python.org/packages/source/s/setuptools/setuptools-0.6c11.tar.gz

tar zxvf setuptools-0.6c11.tar.gz

cd setuptools-0.6c11

python setup.py build

python setup.py install


4.2  ImportError: cannot import name HTTPSHandler解決辦法

yum安裝openssl和openssl-devel,然後重新編譯python


五、pip參數解釋

# pip --help

 

Usage:   

  pip <command> [options]

 

Commands:

  install                     安裝包.

  uninstall                   卸載包.

  freeze                      按著一定格式輸出已安裝包列表

  list                        列出已安裝包.

  show                        顯示包詳細資料.

  search                      搜尋包,類似yum裡的search.

  wheel                       Build wheels from your requirements.

  zip                         不推薦. Zip individual packages.

  unzip                       不推薦. Unzip individual packages.

  bundle                      不推薦. Create pybundles.

  help                        當前協助.

 

General Options:

  -h, --help                  顯示協助.

  -v, --verbose               更多的輸出,最多可以使用3次

  -V, --version               現實版本資訊然後退出.

  -q, --quiet                 最少的輸出.

  --log-file <path>           覆蓋的方式記錄verbose錯誤記錄檔,預設檔案:/root/.pip/pip.log

  --log <path>                不覆蓋記錄verbose輸出的日誌.

  --proxy <proxy>             Specify a proxy in the form [user:[email protected]]proxy.server:port.

  --timeout <sec>             連線逾時時間 (預設15秒).

  --exists-action <action>    Default action when a path already exists: (s)witch, (i)gnore, (w)ipe, (b)ackup.

  --cert <path>               認證.


(end)

本文出自 “小五台車神” 部落格,請務必保留此出處http://linuxtech.blog.51cto.com/3670088/1731147

centos系統下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.