我是Python的新手,正在尝试在Windows7上使用> pip install linkchecker
。
无论软件包是什么,
> pip install scrapy
也会导致SSL错误。Python3.4.1的> pip search linkchecker
works之前,无法从命令行使用python
和pip
。也许这是因为pip搜索不会在公司网络中验证站点的SSL am,但我们不会通过代理来访问Internet.以下是运行pip install linkchecker
后我的pip.log的内容
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
发布于 2015-04-20 23:13:41
pip install gensim config --global http.sslVerify false
只需使用"config --global http.sslVerify false“语句安装任何软件包
您可以通过将pypi.org
和files.pythonhosted.org
以及较旧的pypi.python.org
设置为受信任的主机来忽略SSL错误。
$ pip install --trusted-host pypi.org --trusted-host pypi.python.org --trusted-host files.pythonhosted.org <package_name>
注意:在2018年4月的某个时候,Python Package Index从pypi.python.org
迁移到了pypi.org
。这意味着使用旧域的"trusted-host“命令不再有效,但您可以同时添加这两个命令。
永久修复
自从pip 10.0发布以来,您应该能够通过升级pip
本身来永久地修复这个问题:
$ pip install --trusted-host pypi.org --trusted-host pypi.python.org --trusted-host files.pythonhosted.org pip setuptools
或者仅通过reinstalling it获取最新版本:
$ curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
(…(然后使用相关的Python解释器运行get-pip.py
)。
在此之后,pip install <otherpackage>
应该就可以工作了。如果没有,那么您将需要执行更多操作,如下所述。
您可能想要add the trusted hosts and proxy to your config file。
pip.ini
(Windows)或pip.conf
(unix)
[global]
trusted-host = pypi.python.org
pypi.org
files.pythonhosted.org
备用解决方案(安全性较低)
大多数答案可能会带来安全问题。
帮助轻松安装大多数python包的两种解决方法是:
easy_install <package_name>
。请注意,有些软件包将找不到或会给出small errors.pip install wheel_package_name.whl
安装软件包。发布于 2014-09-26 22:59:53
您可以使用此参数指定证书:
pip --cert /etc/ssl/certs/FOO_Root_CA.pem install linkchecker
请参阅:Docs » Reference Guide » pip
如果指定公司的根证书不起作用,也许cURL根证书可以起作用:http://curl.haxx.se/ca/cacert.pem
您必须使用PEM文件,而不是CRT文件。如果你有一个CRT文件,你将需要 ,在评论中有报告说这现在与CRT文件一起工作,但我还没有验证。
还可以检查:SSL Cert Verification。
发布于 2018-08-24 22:24:08
对我来说,这个问题是通过创建一个文件夹pip
来修复的,在C:\Users\<username>\AppData\Roaming\
中包含一个文件:pip.ini
。例如:
C:\Users\<username>\AppData\Roaming\pip\pip.ini
我在里面写道:
[global]
trusted-host = pypi.python.org
pypi.org
files.pythonhosted.org
我重新启动了python,然后pip永久信任这些站点,并使用它们从下载包。
如果你在windows上找不到AppData文件夹,在文件资源管理器中输入%appdata%
,它就会出现。
https://stackoverflow.com/questions/25981703
复制相似问题