程序员最近都爱上了这个网站  程序员们快来瞅瞅吧!  it98k网:it98k.com

本站消息

站长简介/公众号

  出租广告位,需要合作请联系站长

+关注
已关注

分类  

暂无分类

标签  

暂无标签

日期归档  

暂无数据

pip install失败,出现“连接错误:[SSL:CERTIFICATE_VERIFY_FAILED]证书验证失败(_ssl.c:598)”

发布于2019-08-21 12:01     阅读(608)     评论(0)     点赞(4)     收藏(0)


我是Python的新手,并试图> pip install linkchecker在Windows 7上。一些说明:

  • 无论封装,pip安装都失败了。例如,> pip install scrapy也会导致SSL错误。
  • Python 3.4.1的Vanilla安装包括pip 1.5.6。我尝试做的第一件事是安装linkchecker。Python 2.7已经安装,它随ArcGIS一起提供。pythonpip直到我安装3.4.1中不具备的命令行。
  • > pip search linkchecker作品。也许这是因为pip搜索不会验证网站的SSL证书。
  • 我在公司网络中,但我们没有通过代理来访问互联网。
  • 每台公司计算机(包括我的计算机)都有一个受信任的根证书颁发机构,其使用原因有多种,包括支持监控TLS流量到https://google.com不确定这是否与它有关。

以下是运行后我的pip.log的内容pip install linkchecker

Downloading/unpacking linkchecker
  Getting page https://pypi.python.org/simple/linkchecker/
  Could not fetch URL https://pypi.python.org/simple/linkchecker/: connection error: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:598)
  Will skip URL https://pypi.python.org/simple/linkchecker/ when looking for download links for linkchecker
  Getting page https://pypi.python.org/simple/
  Could not fetch URL https://pypi.python.org/simple/: connection error: HTTPSConnectionPool(host='pypi.python.org', port=443): Max retries exceeded with url: /simple/ (Caused by <class 'http.client.CannotSendRequest'>: Request-sent)
  Will skip URL https://pypi.python.org/simple/ when looking for download links for linkchecker
  Cannot fetch index base URL https://pypi.python.org/simple/
  URLs to search for versions for linkchecker:
  * https://pypi.python.org/simple/linkchecker/
  Getting page https://pypi.python.org/simple/linkchecker/
  Could not fetch URL https://pypi.python.org/simple/linkchecker/: connection error: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:598)
  Will skip URL https://pypi.python.org/simple/linkchecker/ when looking for download links for linkchecker
  Could not find any downloads that satisfy the requirement linkchecker
Cleaning up...
  Removing temporary dir C:\Users\jcook\AppData\Local\Temp\pip_build_jcook...
No distributions at all found for linkchecker
Exception information:
Traceback (most recent call last):
  File "C:\Python34\lib\site-packages\pip\basecommand.py", line 122, in main
    status = self.run(options, args)
  File "C:\Python34\lib\site-packages\pip\commands\install.py", line 278, in run
    requirement_set.prepare_files(finder, force_root_egg_info=self.bundle, bundle=self.bundle)
  File "C:\Python34\lib\site-packages\pip\req.py", line 1177, in prepare_files
    url = finder.find_requirement(req_to_install, upgrade=self.upgrade)
  File "C:\Python34\lib\site-packages\pip\index.py", line 277, in find_requirement
    raise DistributionNotFound('No distributions at all found for %s' % req)
pip.exceptions.DistributionNotFound: No distributions at all found for linkchecker

解决方案


您可以通过设置pypi.orgfiles.pythonhosted.org作为可信主机来忽略SSL错误

$ pip install --trusted-host pypi.org --trusted-host files.pythonhosted.org <package_name>

注意:在2018年4月的某个时间,Python Package Index已迁移pypi.python.orgpypi.org这意味着使用旧域的“trusted-host”命令不再起作用。

永久修复

自从pip 10.0发布以来,你应该能够通过pip自我升级来永久修复它:

$ pip install --trusted-host pypi.org --trusted-host files.pythonhosted.org pip setuptools

或者只是重新安装它以获得最新版本:

$ curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py

(...然后get-pip.py使用相关的Python解释器运行)。

pip install <otherpackage>应该在此之后工作。如果没有,那么您将需要做更多,如下所述。


您可能希望将可信主机和代理添加到配置文件中

pip.ini(Windows)或pip.conf(unix)

[global]
trusted-host = pypi.python.org
               pypi.org
               files.pythonhosted.org

替代解决方案(不太安全)

大多数答案可能会带来安全问题。

有助于轻松安装大多数python包的两个解决方法是:

  • 使用easy_install:如果你真的很懒,不想浪费太多时间,请使用easy_install <package_name>请注意,找不到某些包或会出现小错误。
  • 使用Wheel:下载python包Wheel并使用pip命令pip install wheel_package_name.whl安装包。


所属网站分类: 技术文章 > 问答

作者:黑洞官方问答小能手

链接:https://www.pythonheidong.com/blog/article/50259/1a5f5186b51b7fb887dc/

来源:python黑洞网

任何形式的转载都请注明出处,如有侵权 一经发现 必将追究其法律责任

4 0
收藏该文
已收藏

评论内容:(最多支持255个字符)