快速跳转:
三、报错ValueError: check_hostname requires server_hostname
五、ERROR: Could not find a version that satisfies the requirement
镜像源使用方法
适用于 windows、linux、macOS 等多种操作系统,方式一样
直接在安装包的命令后面加 -i pip 源网址,如:
pip install torch==1.8.1 -i https://mirrors.aliyun.com/pypi/simple/
中国常见的 pip 镜像源
按照完全度和下载速度排序,需要注意的是,
镜像源的完全度和速度可能因地域和时间而异,建议根据自己的实际情况选择合适的镜像源。
1.1 清华大学(完全度和速度都很好)
https://pypi.tuna.tsinghua.edu.cn/simple
1.2 阿里云(完全度和速度也很好,是一个不错的选择)
https://mirrors.aliyun.com/pypi/simple/
1.3 网易(速度比较快,但是完全度有限)
https://mirrors.163.com/pypi/simple/
1.4 豆瓣(速度较快,但是完全度也有限)
https://pypi.douban.com/simple/
1.5 百度云(速度较快,但是完全度也有限)
https://mirror.baidu.com/pypi/simple/
1.6 中科大(速度较快,但完全度不如前面几个镜像源)
https://pypi.mirrors.ustc.edu.cn/simple/
1.7 华为云(完全度和速度均中等)
https://mirrors.huaweicloud.com/repository/pypi/simple/
1.8 腾讯云(速度一般,完全度也一般)
https://mirrors.cloud.tencent.com/pypi/simple/
常见问题:
一、pip版本问题
例如执行:
pip install ddddocr -i https://pypi.tuna.tsinghua.edu.cn/simple --trusted-host
pypi.tuna.tsinghua.edu.cn
报错如下:
原因为:pip 的版本低了,升级 pip 版本后重新执行安装即可
python -m pip install --upgrade pip
重装后执行成功
二、报错Read timed out
由于时间长了之后会出现time out的错误
1、添加限制时间解决
pip --default-timeout=1000 install xxx
2、使用本文上方国内镜像源
三、报错ValueError: check_hostname requires server_hostname
通常访问外网的时候就需要使用代理,所以pip认为这不安全,就不给你安装了
解决方案:关闭代理
四、pip安装一些numpy时报的错
加了国内镜像源还是报错,问题原因时不被信任的主机
解决方案:使用“–trusted host pypi.douban.com”信任
pip install numpy -i http://pypi.douban.com/simple --trusted-host pypi.douban.com
完美解决
五、ERROR: Could not find a version that satisfies the requirement
问题原因:找不到该版本。
解决方法:直接去掉后面包的版本号解决。