pip安裝使用詳解

2021-08-20 03:33:33 字數 4050 閱讀 6773

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

# wget "" --no-check-certificate

# wget "" --no-check-certificate

1.2 pip安裝

# tar -xzvf pip-1.5.4.tar.gz # cd pip-1.5.4 # python setup.py install

# tar -xzvf pip-1.5.4.tar.gz

# cd pip-1.5.4

# python setup.py install

2.1 pip安裝包

# pip install somepackage   [...]   successfully installed somepackage

# pip install somepackage

successfully installed somepackage

2.2 pip檢視已安裝的包

# pip show --files somepackage   name: somepackage   version: 1.0   location: /my/env/lib/pythonx.x/site-packages   files:    ../somepackage/__init__.py    [...]

# pip show --files somepackage

name: somepackage

version: 1.0

location: /my/env/lib/pythonx.x/site-packages

files:

../somepackage/__init__.py

2.3 pip檢查哪些包需要更新

# pip list --outdated   somepackage (current: 1.0 latest: 2.0)

# pip list --outdated

somepackage (current: 1.0 latest: 2.0)

2.4 pip公升級包

# pip install --upgrade somepackage   [...]   found existing installation: somepackage 1.0   uninstalling somepackage:     successfully uninstalled somepackage   running setup.py install for somepackage   successfully installed somepackage

# pip install --upgrade somepackage

found existing installation: somepackage 1.0

uninstalling somepackage:

successfully uninstalled somepackage

running setup.py install for somepackage

successfully installed somepackage

2.5 pip解除安裝包

$ pip uninstall somepackage   uninstalling somepackage:     /my/env/lib/pythonx.x/site-packages/somepackage   proceed (y/n)? y   successfully uninstalled somepackage

$ pip uninstall somepackage

uninstalling somepackage:

/my/env/lib/pythonx.x/site-packages/somepackage

proceed (y/n)? y

successfully uninstalled somepackage

3.1 安裝redis

# pip install redis

# pip install redis

3.2 解除安裝redis

# pip uninstall redis uninstalling redis:   /usr/lib/python2.6/site-packages/redis-2.9.1-py2.6.egg-info .....省略一些內容.... proceed (y/n)? y   successfully uninstalled redis

# pip uninstall redis

uninstalling redis:

/usr/lib/python2.6/site-packages/redis-2.9.1-py2.6.egg-info

.....省略一些內容....

proceed (y/n)? y

successfully uninstalled redis

3.3 檢視待更新包

pip list --outdate pygpgme (current: 0.1 latest: 0.3) pycurl (current: 7.19.0 latest: 7.19.3.1) iniparse (current: 0.3.1 latest: 0.4)

pip list --outdate

pygpgme (current: 0.1 latest: 0.3)

pycurl (current: 7.19.0 latest: 7.19.3.1)

iniparse (current: 0.3.1 latest: 0.4)

4.1 importerror no module named setuptools

請參考《importerror no module named setuptools解決》

# pip --help

usage:   

pip [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 覆蓋的方式記錄verbose錯誤日誌,預設檔案:/root/.pip/pip.log

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

--proxy specify a proxy in the form [user:passwd@]proxy.server:port.

--timeout 連線超時時間 (預設15秒).

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

--cert 證書.

安裝使用一目了然,太簡單了。

pip 安裝使用詳解

pip類似redhat裡面的yum,安裝python包非常方便。本節詳細介紹pip的安裝 以及使用方法。wget no check certificate 1.2 pip安裝 tar xzvf pip 1.5.4.tar.gz cd pip 1.5.4 python setup.py install...

pip安裝使用詳解

pip類似centos裡面的yum,安裝python包非常方便。本節詳細介紹pip的安裝 以及使用方法。windows安裝 windows版本在2.7.9及以上版本才提供的有pip的安裝,安裝python的時候缺省會安裝pip,但是需要選中add python.ext to path,這個安裝成功後...

pip安裝使用詳解

1 wget no check certificate 1.2 pip安裝 tar xzvf pip 1.5.4.tar.gz cd pip 1.5.4 python setup.py install 2.pip使用詳解 2.1 pip安裝包 pip install somepackage succ...