代码改变世界

pip或easy_install安装库报错:SSL: CERTIFICATE_VERIFY_FAILED

2018-02-01 15:41  ZengGW  阅读(9484)  评论(0编辑  收藏  举报

  使用pip和easy_install安装那个lxml、pyspider这些库或者框架一直提示以下错误:

Collecting pyspider
  Could not fetch URL https://pypi.python.org/simple/pyspider/: There was a prob
lem confirming the ssl certificate: [SSL: CERTIFICATE_VERIFY_FAILED] certificate
 verify failed (_ssl.c:661) - skipping
  Could not find a version that satisfies the requirement pyspider (from version
s: )
No matching distribution found for pyspider
Searching for pyspider
Reading https://pypi.python.org/simple/pyspider/
Download error on https://pypi.python.org/simple/pyspider/: [SSL: CERTIFICATE_VE
RIFY_FAILED] certificate verify failed (_ssl.c:661) -- Some packages may not be
found!
Couldn't find index page for 'pyspider' (maybe misspelled?)
Scanning index of all packages (this may take a while)
Reading https://pypi.python.org/simple/
Download error on https://pypi.python.org/simple/: [SSL: CERTIFICATE_VERIFY_FAIL
ED] certificate verify failed (_ssl.c:661) -- Some packages may not be found!
No local packages or working download links found for pyspider
error: Could not find suitable distribution for Requirement.parse('pyspider')

  错误原因:SSL:CERTIFICATE_VERIFY_FAILED]证书验证失败(_ssl.c:661)

  解决办法:

# 1.pip install --index-url=http://pypi.python.org/simple/ --trusted-host pypi.python.org pythonPackageName
# 2.pip --trusted-host pypi.python.org install pythonPackageName

  以上两种命令都行,其中 "pythonPackageName" 是你要安装的库名称(比如:requests、lxml等)