python中pip安装库时出现Read timed out怎么解决(pip,python,开发技术)

时间:2024-04-28 02:57:49 作者 : 石家庄SEO 分类 : 开发技术
  • TAG :

首先,我先更新了pip,如下图:

python中pip安装库时出现Read timed out怎么解决

顺便附上成功截图:

python中pip安装库时出现Read timed out怎么解决

然后安装numpy库:

python中pip安装库时出现Read timed out怎么解决

用这种常规方法安装库会出现time out,也就是超时的情况,以下是我的解决方法:

解决办法1:延长timeout时间

raise ReadTimeoutError(self._pool, None, 'Read timed out.')
ReadTimeoutError: HTTPSConnectionPool(host='files.pythonhosted.org', port=443): Read timed out.

pip --default-timeout=100 install Package
将Package替换你所需要的库就行

解决办法2:换源,将pip源更换到国内镜像,个人比较推荐这种方法

#例如安装scipy时使用豆瓣的源pipinstall--index-urlhttps://pypi.douban.com/simplescipy#使用清华大学的源pipinstall-ihttps://pypi.tuna.tsinghua.edu.cn/simple–upgradetensorflow-gpu

将pip源更换到国内镜像
用pip管理工具安装库文件时,默认使用国外的源文件,因此在国内的下载速度会比较慢,可能只有50KB/s。幸好,国内的一些顶级科研机构已经给我们准备好了各种镜像,下载速度可达2MB/s。
其中,比较常用的国内镜像包括:

(1)阿里云 http://mirrors.aliyun.com/pypi/simple/
(2)豆瓣http://pypi.douban.com/simple/
(3)清华大学 https://pypi.tuna.tsinghua.edu.cn/simple/
(4)中国科学技术大学 http://pypi.mirrors.ustc.edu.cn/simple/

以清华源为例,设置方法如下:

可以在使用pip的时候,加上参数-i和镜像地址(如https://pypi.tuna.tsinghua.edu.cn/simple),

例如:pip install -i https://pypi.tuna.tsinghua.edu.cn/simple pandas,这样就会从清华镜像安装pandas库。

python中pip安装库时出现Read timed out怎么解决

成功截图如下:

python中pip安装库时出现Read timed out怎么解决

同样的方法我又下载了matplotlib库:

python中pip安装库时出现Read timed out怎么解决

安装完后回到python就可以导入相应的包啦

最后成功画圆啦

python中pip安装库时出现Read timed out怎么解决

 </div> <div class="zixun-tj-product adv-bottom"></div> </div> </div> <div class="prve-next-news">
本文:python中pip安装库时出现Read timed out怎么解决的详细内容,希望对您有所帮助,信息来源于网络。
上一篇:PostgreSQL Node.js怎么实现函数计算方法下一篇:

37 人围观 / 0 条评论 ↓快速评论↓

(必须)

(必须,保密)

阿狸1 阿狸2 阿狸3 阿狸4 阿狸5 阿狸6 阿狸7 阿狸8 阿狸9 阿狸10 阿狸11 阿狸12 阿狸13 阿狸14 阿狸15 阿狸16 阿狸17 阿狸18