pip快速下载安装Python第三方库

39 阅读1分钟

持续创作,加速成长!这是我参与「掘金日新计划 · 10 月更文挑战」的第28天,点击查看活动详情

主要内容

成功解决python安装库过程中Read timed out报错。

问题

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

解决方案

// 例如在给pip升级时:
pip --default-timeout=100 install --upgrade pip
// 安装库
pip --default-timeout=6000 install xxx

==使用国内源提高下载速度==

'''
python国内镜像源
1. 清华:https://pypi.tuna.tsinghua.edu.cn/simple
2. 豆瓣:https://pypi.douban.com/simple/
3. 阿里云:https://mirrors.aliyun.com/pypi/simple/
4. 中国科技大学:https://pypi.mirrors.ustc.edu.cn/simple/
5. 华中理工大学:https://pypi.hustunique.com/
6. 山东理工大学:https://pypi.sdutlinux.org/
7. '''

'''
安装第三方库(例如最新版tensorflow)
'''
pip --default-timeout=6000 install tensorflow -i https://pypi.doubanio.com/simple/
'''
安装第三方库(例如tensorflow-gpu==2.3.0)
'''
pip --default-timeout=6000 install tensorflow-gpu==2.3.0 -i https://pypi.doubanio.com/simple/

其他常用命令

pip list 查看所有第三方库

pip show pandas 展示某个第三方库的版本及相关信息