Python pip 常用命令

来源:互联网 发布:社交网络发展的好处 编辑:程序博客网 时间:2024/05/29 14:52

列出已安装的包

pip freeze

或者

pip list

安装包

在线安装

pip install <SomePackage>

本地安装

pip install <dir>/<file>

或者

pip install --use-wheel --no-index --find-links=wheelhouse/ <SomePackage>

后者可简写为:

pip install --no-index -f=<dir>/ <SomePackage>

卸载包

pip uninstall <SomePackage>

搜索包

pip search <keywords>

升级包

pip install -U <SomePackage>

升级pip

pip install -U pip

显示包所在的目录

pip show -f <SomePackage>

查询可升级的包

pip list -o

下载包而不安装

pip install <SomePackage> -d <dir>

打包

pip wheel <SomePackage>

从其他镜像源安装

指定单次安装源

pip install <SomePackage> -i http://pypi.v2ex.com/simple

指定全局安装源

更改pip配置文件
在Unix和MacOS上为:$HOME/.pip/pip.conf
在Windows上为:%HOME%\pip\pip.ini

[global]timeout = 6000index-url = http://pypi.douban.com/simple

一些国内pypi镜像

  • 豆瓣:https://pypi.douban.com/simple
  • 中国科学技术大学:https://mirrors.tuna.tsinghua.edu.cn/pypi/web/simple/
  • 清华大学TUNA:https://pypi.tuna.tsinghua.edu.cn/simple

pip官方文档

https://pip.pypa.io/en/latest/

原创粉丝点击