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

2024-04-30 02:43:07 发布

您现在位置:Python中文网/ 问答频道 /正文

我已经成功地在本地计算机上安装了Python 3.4和python3.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>安装软件包?


Tags: installpiptheurlsslpackagethatis
3条回答

如果您在Windows上使用anaconda,这对我有效:

我尝试了许多其他不起作用的解决方案(环境路径变量更改…)

此问题可能是由其他软件放置在Windows\System32文件夹中的dll(例如libcrypto-1_1-x64.dll或libssl-1_1-x64.dll或其他)引起的。

修复程序是从https://slproweb.com/products/Win32OpenSSL.html安装openSSL,它用更新的版本替换dll。

如果您在Red Hat/CentOS上:

# To allow for building python ssl libs
yum install openssl-devel
# Download the source of *any* python version
cd /usr/src
wget https://www.python.org/ftp/python/3.6.2/Python-3.6.2.tar.xz
tar xf Python-3.6.2.tar.xz 
cd Python-3.6.2

# Configure the build w/ your installed libraries
./configure

# Install into /usr/local/bin/python3.6, don't overwrite global python bin
make altinstall

在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. 构建并安装:$ sudo make && sudo make install

  5. 安装软件包时使用:$ pip3 install package_name

相关问题 更多 >