python更改下载源地址 (WARNING: The repository located at mirrors.aliyun.com is not a tr

作者 jvip_chen, 2023-2月-16 04:43 下午

« 上一篇主题 - 下一篇主题 »

jvip_chen

python更改下载源地址
python默认的pip源在国外,如果下载比较大的第三方库时可能会非常非常慢,甚至会报错,所以为了有一个更加友好的python使用体验,建议为python的pip换一下源。

临时使用pip源

在使用pip时候,后面加上参数-i 镜像地址,例如:

pip3 install pygame -i http://mirrors.aliyun.com/pypi/simple/
永久修改:

pip config set global.index-url http://mirrors.aliyun.com/pypi/simple/

[root@localhost bin]# ./pip config set global.index-url http://mirrors.aliyun.com/pypi/simple/Writing to /root/.config/pip/pip.conf工作中遇到的问题总结
WARNING: The repository located at mirrors.aliyun.com is not a trusted
WARNING: The repository located at mirrors.aliyun.com is not a trusted or secure host and is being ignored. If this repository is available via HTTPS we recommend you use HTTPS instead, otherwise you may silence this warning and allow it anyway with '–trusted-host mirrors.aliyun.com'.
ERROR: Could not find a version that satisfies the requirement Pillow3.4.2 (from versions: none)
ERROR: No matching distribution found for Pillow3.4.2
WARNING: The repository located at mirrors.aliyun.com is not a trusted or secure host and is being ignored. If this repository is available via HTTPS we recommend you use HTTPS instead, otherwise you may silence this warning and allow it anyway with '–trusted-host mirrors.aliyun.com'.

解决方法:根据错误提醒,添加 --trusted-host mirrors.aliyun.com 即可,如下

[root@localhost bin]# ./pip install -r requirements.txt --trusted-host mirrors.aliyun.com