pip 卸载大法
pip install pip-autoremove
pip-autoremove jupyter
pip 加速(使用代理)
pip 加速(使用镜像)
- 临时使用镜像,命令行使用参数项-i
pip install 模块名 -i https://pypi.douban.com/simple/
自动配置
pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple
手动配置,pip 添加配置文件
查看用户主目录下有没有”~/.pip/pip.conf”文件,没有则创建。
mkdir .pip
touch .pip/pip.conf
打开文件,添加以下配置项
[global]
index-url=http://pypi.douban.com/simple
[install]
trusted-host=pypi.douban.com
可选镜像网址
豆瓣
[global]
index-url=http://pypi.douban.com/simple
[install]
trusted-host=pypi.douban.com
阿里云
[global]
index-url=http://mirrors.aliyun.com/pypi/simple
[install]
trusted-host=mirrors.aliyun.com
清华大学
[global]
index-url=https://pypi.tuna.tsinghua.edu.cn/simple
[install]
trusted-host=pypi.tuna.tsinghua.edu.cn
pip 配置文件
首先检测配置文件是否存在,没有则创建之。配置文件的路径(本用户有效):
- Unix:
$HOME/.config/pip/pip.conf
- Mac:
$HOME/Library/Application Support/pip/pip.conf
- Windows:
%APPDATA%\pip\pip.ini
,%APPDATA%
的实际路径我电脑上是C:\Users\user_xxx\AppData\Roaming
,可在 cmd 里执行echo %APPDATA%
命令查看
virtualenv 和全局的配置文件路径参见 pip文档
配置文件内容如下:
[global]
index-url = http://mirrors.aliyun.com/pypi/simple/ # 这里使用的是阿里云的镜像源
proxy=http://xxx.xxx.xxx.xxx:8080 # 替换出自己的代理地址,格式为[user:passwd@]proxy.server:port
[install]
trusted-host=mirrors.aliyun.com # 信任阿里云的镜像源,否则会有警告
配置文件的原则就是,凡是pip命令行的参数都可以在配置文件里定义其默认值!
至于[global]、[install]等标志我没找到具体说明,估计是配置参数的作用范围。
我的配置
C:\Users\DP\AppData\Roaming\pip\pip.ini
[global]
proxy=http://127.0.0.1:1080