python:關於pip

avatus發表於2018-09-03

python pip安裝包的一些常用命令:

1 羅列出所有安裝過的包:

pip list 或 pip freeze

2 安裝包:

2.1 直接安裝

$ pip install SomePackage            # 預設最新版
$ pip install SomePackage==1.0.4     # 某個指定版
$ pip install `SomePackage>=1.0.4`     # 某個版本以上

2.2 從包列表檔案裡面依次安裝

pip install -r example-requirements.txt 關於 example-requirements.txt:

#
####### example-requirements.txt #######
#
###### Requirements without Version Specifiers ######
nose
nose-cov
beautifulsoup4
#
###### Requirements with Version Specifiers ######
#   See https://www.python.org/dev/peps/pep-0440/#version-specifiers
docopt == 0.6.1             # Version Matching. Must be version 0.6.1
keyring >= 4.1.1            # Minimum version 4.1.1
coverage != 3.5             # Version Exclusion. Anything except version 3.5
Mopidy-Dirble ~= 1.1        # Compatible release. Same as >= 1.1, == 1.*
#
###### Refer to other requirements files ######
-r other-requirements.txt
#
#
###### A particular file ######
./downloads/numpy-1.9.2-cp34-none-win32.whl
http://wxpython.org/Phoenix/snapshot-builds/wxPython_Phoenix-3.0.3.dev1820+49a8884-cp34-none-win_amd64.whl
#
###### Additional Requirements without Version Specifiers ######
#   Same as 1st section, just here to show that you can put things in any order.
rejected
green
#

2.3 指定安裝的源

pip install SomePackage -i https://pypi.tuna.tsinghua.edu.cn/simple

3 升級包

pip install -U SomePackage

pip install --upgrade SomePackage

4 解除安裝包

pip uninstall SomePackage  或者 pip uninstall -r list.txt

5 顯示某個包的資訊….包所含檔案列表:

pip show -f SomePackage

6 搜尋包

pip search keyword

7 查詢可升級包

pip list -o


相關文章