pip install 一些包总是超时,Python的pip不能用了吗?
pip install 一些包总是超时,pip 不能用了吗?使用国内源也是这种情况
pip install 一些包总是超时,Python的pip不能用了吗?
5 回复
windowns %USERPROFILE%\pip\pip.ini
# linux ~/.pip/pip.conf
[global]
index-url = https://pypi.douban.com/simple
# https://pypi.douban.com/simple
# https://pypi.mirrors.ustc.edu.cn/simple
# https://pypi.tuna.tsinghua.edu.cn/simple
# https://pypi.zenlogic.net/simple/
[list]
format=columns
pip install 超时通常是因为默认的PyPI源在国内访问较慢。最直接的解决方法是更换为国内的镜像源。
临时使用镜像源(单次安装):
pip install 包名 -i https://pypi.tuna.tsinghua.edu.cn/simple
永久配置镜像源(推荐):
- 创建或修改pip配置文件:
- Linux/Mac:
~/.pip/pip.conf - Windows:
%APPDATA%\pip\pip.ini
- Linux/Mac:
- 添加以下内容:
[global]
index-url = https://pypi.tuna.tsinghua.edu.cn/simple
trusted-host = pypi.tuna.tsinghua.edu.cn
常用国内镜像源:
- 清华:
https://pypi.tuna.tsinghua.edu.cn/simple - 阿里云:
https://mirrors.aliyun.com/pypi/simple/ - 豆瓣:
http://pypi.douban.com/simple/
如果更换镜像源后仍超时,检查网络连接或尝试增加超时时间:--default-timeout=100。
总结:换国内镜像源就能解决。
你检查一下 你设置国内源失效了么?
就是当超时的时候,看一下 他连接的地址, 可以看出来是不是你这设置的源
如果发现是国内源设置没有生效的话,可以看这篇 https://stackoverflow.com/questions/28278207/python-cant-find-pip-ini-or-pip-conf-in-windows7
国内源一切正常. 国外源主要是慢.
非常感谢,原来是使用的国外源,现在换成国内的了,正常了

