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

本文介绍如何更改Python的pip源以提高下载速度。通过临时或永久设置国内镜像站点,如阿里云镜像,可以有效解决下载缓慢的问题,并提供解决信任警告的方法。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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/

豆瓣・・・・・・・・・・・・・・・http://pypi.douban.com/
华中理工大学・・・・・・・・http://pypi.hustunique.com/
山东理工大学・・・・・・・・http://pypi.sdutlinux.org/
中国科学技术大学・・・・http://pypi.mirrors.ustc.edu.cn/
阿里云・・・・・・・・・・・・・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 Pillow
3.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
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

西京刀客

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值