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