pip常用命令、配置pip源

时间:2023-03-09 01:13:51
pip常用命令、配置pip源

1、查找软件

# pip search Package

2、安装软件

# pip install Package
# pip install -r requirements.txt

3、更新软件

# pip install -U Package

4、卸载软件

# pip uninstall Package

5、列出已安装软件

# pip list
# pip freeze
# pip freeze -r requirements.txt

6、查看一个软件包时安装了哪些文件

# pip show -f Package

7、命令补全

# pip completion --bash >> .bash_profile

8、升级所有包

# for i in `pip list --outdated --trusted-host pypi.douban.com | tail -n +3 | awk '{print $1}'`; do pip install -U $i; done

9、修改pip安装源。在mac上需要自己创建.pip/目录和配置文件。

# mkdir ~/.pip
# vim ~/.pip/pip.conf # 阿里源
[global]
index-url = http://mirrors.aliyun.com/pypi/simple/
trusted-host = mirrors.aliyun.com # 豆瓣源
[global]
index-url = http://pypi.douban.com/simple
trusted-host = pypi.douban.com