You can ignore SSL errors by setting pypi.org
and files.pythonhosted.org
as trusted hosts.
(您可以通过将pypi.org
和files.pythonhosted.org
设置为可信主机来忽略SSL错误。)
$ pip install --trusted-host pypi.org --trusted-host files.pythonhosted.org <package_name>
Note : Sometime during April 2018, the Python Package Index was migrated from pypi.python.org
to pypi.org
.
(注意 :在2018年4月的某个时候, Python软件包索引已从pypi.python.org
迁移到pypi.org
。)
This means "trusted-host" commands using the old domain no longer work. (这意味着使用旧域的“受信任主机”命令不再起作用。)
Permanent Fix (永久修复)
Since the release of pip 10.0, you should be able to fix this permanently just by upgrading pip
itself:
(从pip 10.0版本发布以来,您应该能够仅通过升级pip
本身来永久修复此问题:)
$ pip install --trusted-host pypi.org --trusted-host files.pythonhosted.org pip setuptools
Or by just reinstalling it to get the latest version:
(或者通过重新安装以获得最新版本:)
$ curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
(… and then running get-pip.py
with the relevant Python interpreter).
((…,然后使用相关的Python解释器运行get-pip.py
)。)
pip install <otherpackage>
should just work after this.
(pip install <otherpackage>
应该在此之后工作。)
If not, then you will need to do more, as explained below. (如果没有,那么您将需要做更多的事情,如下所述。)
You may want to add the trusted hosts and proxy to your config file .
(您可能需要将信任的主机和代理添加到配置文件中 。)
pip.ini
(Windows) or pip.conf
(unix)
(pip.ini
(Windows)或pip.conf
(unix))
[global]
trusted-host = pypi.python.org
pypi.org
files.pythonhosted.org
Alternate Solutions (Less secure)
(替代解决方案(安全程度较低))
Most of the answers could pose a security issue.
(大多数答案可能会带来安全问题。)
Two of the workarounds that help in installing most of the python packages with ease would be:
(有助于轻松安装大多数python软件包的两种解决方法是:)
- Using easy_install : if you are really lazy and don't want to waste much time, use
easy_install <package_name>
. (使用easy_install :如果您真的很懒,不想浪费很多时间,请使用easy_install <package_name>
。)
Note that some packages won't be found or will give small errors. (请注意,找不到某些软件包,或者会产生一些小错误。)
- Using Wheel : download the Wheel of the python package and use the pip command
pip install wheel_package_name.whl
to install the package. (使用Wheel :下载python软件包的Wheel并使用pip命令pip install wheel_package_name.whl
安装该软件包。)