python各种安装包失败
2020-01-05 本文已影响0人
神之试炼者
背景:
差不多每次安装python就遇到各种下载包失败, ...郁闷之情难以言表
1. 下载包超时 [timeout]
公司网络有限制, 而且默认国外的pip仓库太卡, 需要配置国内镜像仓库.
常用国内仓库
清华:https://pypi.tuna.tsinghua.edu.cn/simple
阿里云:http://mirrors.aliyun.com/pypi/simple/
中国科技大学 https://pypi.mirrors.ustc.edu.cn/simple/
华中理工大学:http://pypi.hustunique.com/
山东理工大学:http://pypi.sdutlinux.org/
豆瓣:http://pypi.douban.com/simple/
配置之后还是下载失败, 见 2
2. 下载包失败
报错内容:
Collecting pip==19.3.1
The repository located at pypi.douban.com is not a trusted or secure host and is being ignored. If this repository is available via HTTPS it is recommended to use HTTPS instead, otherwise you may silence this warning and allow it anyways with '--trusted-host pypi.douban.com'.
Could not find a version that satisfies the requirement pip==19.3.1 (from versions: )
No matching distribution found for pip==19.3.1
原因:
使用了国内豆瓣仓库不受信任. 加一个信任文件
manager Respositories配置了: https://pypi.doubanio.com/simple/
在对应目录(当前用户下创建pip文件夹)下新建文件:pip.ini [比如我的目录:C:\Users{myname}\pip]
内容如下
[global]
index-url = https://pypi.doubanio.com/simple/
[install]
trusted-host=pypi.doubanio.com
3. 提示版本不支持 [以前遇到过,没留记录]
有时候下载个别包, 比如requests这个常用的. 我上次下载: 提示要求python 3.1,3.2,3.3,3.5...似乎是不支持3.4
所以留意提示中支持的python版本
4. 提示请升级pip
这个也常见, 一般安装好python后,自带的pip版本很低, 导致安装包不支持....升级一下即可[通过命令或直接借助pycharm点击升级]
5. 没安装代理
有时候公司内网,需要安装代理, 在settings 搜索Proxy, 进行设置