使用 pip3 安装包时“Python 中的 ssl 模块不可用”

新手上路,请多包涵

我已在本地计算机上成功安装 Python 3.4 和 Python 3.6,但无法安装带有 pip3 的软件包。

当我执行 pip3 install <package> 时,我收到以下 SSL 相关 错误:

 pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.
Collecting <package>
  Could not fetch URL https://pypi.python.org/simple/<package>/: There was a problem confirming the ssl certificate: Can't connect to HTTPS URL because the SSL module is not available. - skipping
  Could not find a version that satisfies the requirement <package> (from versions: )
No matching distribution found for <package>

如何修复我的 Python3.x 安装,以便我可以使用 pip install <package> 安装软件包?

原文由 Harukaze 发布,翻译遵循 CC BY-SA 4.0 许可协议

阅读 775
1 个回答

在 Ubuntu 中安装 Python 3.6 和 pip3 的分步指南

  1. 为 Python 和 ssl 安装必要的包: $ sudo apt-get install libreadline-gplv2-dev libncursesw5-dev libssl-dev libsqlite3-dev tk-dev libgdbm-dev libc6-dev libbz2-dev

  2. https://www.python.org/ftp/python/ 下载“Python-3.6.8.tar.xz”并将其解压缩到您的主目录中。

  3. 在该目录中打开终端并运行: $ ./configure

  4. 构建并安装: $ make && sudo make install

  5. 安装包: $ pip3 install package_name

免责声明:以上命令未在 Ubuntu 20.04 LTS 中测试。

原文由 arsho 发布,翻译遵循 CC BY-SA 4.0 许可协议

推荐问题