pip安装报错处理+PyPi源切换教程
一、pip安装出错类型
1.1 pip版本过旧导致不能安装
报错提示:
You are using pip version 9.0.3, however version 10.0.1 is available.
You should consider upgrading via the 'python -m pip install --upgrade pip' comm
and.
可通过以下命令升级pip
python -m pip install --upgrade pip
1.2 官方的PyPi连接超时
如果是timeout类形错误,那重点怀疑网络问题,可能是官方的PyPi太慢导致。
这类错误可通过在pip.ini中index-url指定为使用本地源进行处理。我这里以清华源为例,具体操作步骤看下边第二大点。
1.3 HTTPS证书问题
现在很多网站都换成了HTTPS,python验证证书没通过时就会拒绝使用PyPi源,通常报错如下:
Could not fetch URL https://pypi.tuna.tsinghua.edu.cn/simple/gg/: There was a
problem confirming the ssl certificate: HTTPSConnectionPool(host='pypi.tuna.tsin
ghua.edu.cn', port=443): Max retries exceeded with url: /simple/numpy/ (Caused by S
SLError(SSLError(, u'[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed
(_ssl.c:)'),)) - skipping
这类错误可通过在pip.ini中添加trusted-host进行处理。我这里以信任清华源为例,具体操作步骤看下边第二大点。
1.4 缺少VC环境依赖
这类错误处理,一是安装vc环境不过到现在我还不是很明白要装哪个文件,更推荐的做法是使用conda安装第三方库,具体操作参见“PyCharm+Miniconda3安装配置教程” 第二大点查看如何安装conda及参看3.2.2节看如何用conda安装第三方库
通常报错如下:
“distutils.errors.DistutilsPlatformError: Microsoft Visual C++ 14.0 is required” “Command "python setup.py egg_info" failed with error code 1 in C:\Users\ADMINI~1\AppData\Local\Temp\pip-install-6fjrrgj5\cffi\”
20191212更新:
既然说缺少Microsoft Visual C++ 14.0 Build Tools那我们直接给他装上。(需要生成工具的原因,猜测是有些python库并不是单纯的python文件,还有c语言写的需要编译成exe等可执行文件)
visual studio installer下载地址:https://visualstudio.microsoft.com/zh-hans/thank-you-downloading-visual-studio/?sku=Community&rel=16#
两个本质上是一样的,而我们要装的都是一个,即”Microsoft Visual C++ 14.0 Build Tools“(VS中文名翻译成生成工具)。
不管是vs 2015还是vs 2017还vs 2019,用的都是14.x版本只是小版本不一样,我们装最新的即可,比如我这里直接装VS2019的。
由于VS无敌的大,为了避免C盘耗费过多建议修改安装地址。可以只勾选安装生成工具,但我这为了方便装了VS能用于编写C++就不取消色选其他组件了。但不管怎么样VS核心编缉器都是必须安装的,大概是微软为了避免有些小白想装VS最终装了一堆组件编缉器却没见到。
二、将PyPi切换为本地源并处理证书错误
注意:这个创建的pip.ini文件配置对conda等发行版中的pip也生效,因为conda等中的pip本质也是pip。
2.1 查看%APPDATA%
路径【可选】
echo %APPDATA%
2.2 创建 %APPDATA%\pip\目录
我这里直接在cmd使用命令创建。图形界面创的话,上一步我们已查到%APPDATA%
的指向了一层层根着创即可
mkdir %APPDATA%\pip
2.3 创建pip.ini文件
使用文件编辑器创建一个文本,然后输入以下内容,并将其保存到上边的%APPDATA%\pip\目录下,命名为pip.ini即可(注意不要保存成pip,ini.txt)
Linux等是$HOME/.config/pip/pip.conf,index-url行可不需要
[global]
trusted-host = pypi.tuna.tsinghua.edu.cn
index-url = https://pypi.tuna.tsinghua.edu.cn/simple
2.4 验证源成功切换且无报错
我这里以pip安装faker库进行验证,自己随便装什么都行
pip install faker
三、配置代理【可选】
应该来讲在把源设置成国内源后应该来讲,网络网速什么的就应该都没问题了,也就没有配置代理的需求。
但在一些公司访问中不允许pip直接访问外部网站,一定要通过公司代理才能访问,这时就只能配置代理。
配置代理也简单,一样在%APPDATA%\pip\pip.ini的[global]节区中设置proxy值即可。假设代理为“http://proxy.company.com:8080”:
[global]
trusted-host = pypi.tuna.tsinghua.edu.cn
index-url = https://pypi.tuna.tsinghua.edu.cn/simple
proxy = http://proxy.company.com:8080
参考:
https://mirrors.tuna.tsinghua.edu.cn/help/pypi/
http://mirrors.ustc.edu.cn/help/pypi.html
https://superuser.com/questions/727924/pip-and-ssl-certificate-errors
https://stackoverflow.com/questions/9698557/how-to-use-pip-on-windows-behind-an-authenticating-proxy
pip安装报错处理+PyPi源切换教程的更多相关文章
- 安装Tensorflow过程pip安装报错:is not a supported wheel on this platform
安装Tensorflow过程pip安装报错:is not a supported wheel on this platform 通过pip安装wheel镜像时,安装指令为: pip install - ...
- pip安装报错: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProxyError('Cannot connect to proxy
pip安装报错 解决办法: pip install selenium -i http://pypi.douban.com/simple --trusted-host pypi.douban.com
- Python——pip安装报错:is not a supported wheel on this platform
pip安装报错:is not a supported wheel on this platform 可能的原因1:安装的不是对应python版本的库,下载的库名中cp35代表python3.5,其它同 ...
- 使用pip安装报错的处理方法
在新的机子上使用pip安装程序一直报错: Retrying (Retry(total=4, connect=None, read=None, redirect=None)) after connect ...
- 使用pip安装报错的处理方法_2
终端更新pip出错 sudo pip install --upgrade pip : 1.ReadTimeoutError: HTTPSConnectionPool(host='pypi.Python ...
- pip安装报错:is not a supported wheel on this platform
可能的原因1:安装的不是对应python版本的库,下载的库名中cp27代表python2.7,其它同理. 可能的原因2:这个是我遇到的情况(下载的是对应版本的库,然后仍然提示不支持当前平台) 我下载到 ...
- 【python】pip安装报错UnicodeDecodeError: 'ascii' codec can't decode byte 0xc4 in position 7: ordinal not in range(128)
刚安装完python,准备pip安装第三方库的时候出现了一个错误: UnicodeDecodeError: ‘ascii’ code can’t decode byte 0xef in positio ...
- python中使用pip安装报错:Fatal error in launcher... 解决方法
python安装了2和3版本在 cmd 中用pip报的错误为:Fatal error in launcher:Unable to create process using 这是因为你安装了python ...
- pip安装报错:Fatal error in launcher: Unable to create process using '"'
pip安装包报错 解决方案: pip需要升级,可使用以下脚本: python -m pip install -U pip
随机推荐
- MVC杂记
@{ Layout = “…”} To define layout page Equivalent to asp.NET master-page 要定义相当于ASP.Net母版页的页面布局 @mode ...
- CentOS6.X、7.X下Jenkins的安装及使用
一.相关概念 1.1 Jenkins概念: Jenkins是一个功能强大的应用程序,允许持续集成和持续交付项目,无论用的是什么平台.这是一个免费的源代码,可以处理任何类型的构建或持续集成.集成Jenk ...
- 随机--相关(Fisher_Yates算法)
Fisher_Yates算法 void ShuffleArray_Fisher_Yates(char* arr, int len) { int i = len, j; char t ...
- public,protected,private
1.public:public表明该数据成员.成员函数是对所有用户开放的,所有用户都可以直接进行调用 2.private:private表示私有,私有的意思就是除了class自己之外,任何人都不可以直 ...
- 使用http://start.spring.io/ 生成工程
今天学习spring-cloud,无意中发现一个spring提供的构建工程的页面,想记录下,发现有个博客写的很好就直接抄过来了. 原文链接: https://blog.csdn.net/u01050 ...
- Rest数据服务查询类-根据sql查询
Rest数据服务查询类 需要iserver data服务支持,但请求的时候,不依赖SuperMap js lib包. 构造函数:QueryById=function(p_params): p_para ...
- MyBatis配置文件中的常用配置
一.连接数据库的配置单独放在一个properties文件中 之前,我们是直接将数据库的连接配置信息写在了MyBatis的conf.xml文件中,如下: <?xml version="1 ...
- boke练习: springboot整合springSecurity出现的问题,传递csrf
boke练习: springboot整合springSecurity出现的问题,传递csrf freemarker模板 在html页面中加入: <input name="_csrf&q ...
- .net WinForm 的数据绑定
.net WinForm 的数据绑定相当灵活 http://www.cnblogs.com/ydong/archive/2006/04/22/381847.html 原来只知道 Control 类上的 ...
- G.711是一种由国际电信联盟(ITU-T)制定的音频编码方式
http://zh.wikipedia.org/zh-cn/G.711 ITU-T G.711 page ITU-T G.191 software tools for speech and audio ...