1、pip批量安装package
-
将需要安装的包保存在
aa.txt中 -
cd到aa.txt所在目录,运行:
$ pip install -r aa.txt
2、pip批量卸载package
-
将需要卸载的包保存在
aa.txt中 -
cd到aa.txt所在目录,运行:
$ pip uninstall -r aa.txt
附图:
aa.txt——指定版本

aa.txt——不指定版本

备注:需要卸载的包可从pip freeze得到
$ pip freeze # 显示已安装的包名及版本
$ pip freeze > aa.txt # 将已安装的包名及版本写入aa.txt
3、pip换国内源
例:
pip install torch
换源后为:
pip install torch -i https://pypi.tuna.tsinghua.edu.cn/simple
本文介绍如何使用pip进行批量安装和卸载Python包的方法,并提供了如何将pip源更换为国内源的具体步骤。
1786





