【发布时间】:2019-01-16 18:11:16
【问题描述】:
在虚拟机中激活的虚拟环境中,我无法使用 pip 安装任何软件包,因为它会引发 SSL 相关错误。
我正在设置一个虚拟环境(使用 virtualenv)来模拟我将要使用的服务器的设置。因此,我在 Ubuntu 18.04 虚拟机(使用 VirtualBox)中手动(从 tar 文件)安装了特定版本的 python(3.7.0)。一旦我选择的 python 版本开始运行,我就激活了一个虚拟环境。点子版本是 18.1。
当我尝试安装 python 包时出现问题,例如:
$ pip install django
它引发了这个错误:
pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.
Collecting django
Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.")': /simple/django/
Could not fetch URL https://pypi.org/simple/django/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='pypi.org', port=443): Max retries exceeded with url: /simple/django/ (Caused by SSLError("Can't connect to HTTPS URL because the SSL module is not available.")) - skipping
Could not find a version that satisfies the requirement django (from versions: )
No matching distribution found for django
搜索后找到的答案都没有帮助我。由于 pip 不能安装任何东西,它不能安装像 ssl 或 OpenSSL 这样的包。如果有人可以帮助我,我提前非常感谢。
【问题讨论】:
-
你可以使用 Ubuntu 的包管理器来安装 python3.7 而不是使用 tar 文件吗?然后,首先,您可能会默认获得 ssl 模块(它是标准库的一部分)。否则,您可能需要将 ssl 库放入您的 tarball。你是如何制作压缩包的?
-
如果您从源代码压缩包编译 python,那么您没有链接到 OpenSSL,因此没有 SSL 模块。这种情况下的解决方案是删除 python 并重新编译它,链接到 OpenSSL 库。如果您在其他地方下载了发行版,那么它的作者在没有 OpenSSL 的情况下编译了它,并且发行版无法使用;再找一个。
-
仍然,为什么不在 Ubuntu vm 中从 apt-get 安装 python3?
-
@hoefling 如何将它与 OpenSSL 链接?我从 python.org 本身下载了发行版。
-
@JawguyChooser 我没有意识到除了从 .tar 文件安装之外,我怎么能通过其他方式安装 Python 3.7.0。我可以指定 'sudo apt-get install python3.7',安装 3.7.1,但 'sudo apt-get install python3.7.0' 不起作用。
标签: python python-3.x pip virtualenv