语法:
pip -v config
ERROR: Need an action (debug, edit, get, list, set, unset) to perform.
查看
pip -v config list
默认无任何输出。
增加
pip -v config set global.index-url http://mirrors.aliyun.com/pypi/simple/
输出提示:Writing to C:\Users\someone\AppData\Roaming\pip\pip.ini
pip -v config set install.trusted-host mirrors.aliyun.com
再次查看
pip -v config list
输出
global.index-url='http://mirrors.aliyun.com/pypi/simple/'
install.trusted-host='mirrors.aliyun.com'
删除
pip -v config unset global.index-url
pip -v config unset install.trusted-host
文件路径: C:\Users\someone\AppData\Roaming\pip\pip.ini
文件内容:
[global]
index-url = http://mirrors.aliyun.com/pypi/simple/
[install]
trusted-host = mirrors.aliyun.com
重新打开cmd窗口
执行安装:
pip install wheel
可以看到已经可以从镜像网站下载了。
Looking in indexes: http://mirrors.aliyun.com/pypi/simple/
Collecting wheel
Downloading http://mirrors.aliyun.com/pypi/packages/bd/7c/d38a0b30ce22fc26ed7dbc087c6d00851fb3395e9d0dac40bec1f905030c
/wheel-0.38.4-py3-none-any.whl (36 kB)
Installing collected packages: wheel
Successfully installed wheel-0.38.4
WARNING: You are using pip version 21.2.4; however, version 22.3.1 is available.
You should consider upgrading via the 'D:\tool\Python\python.exe -m pip install --upgrade pip' command.
总结:
config list和直接写文件效果一样。