ImportError: urllib3 v2.0 only supports OpenSSL 1.1.1+, currently the 'ssl' module is compiled with 'OpenSSL 1.0.2u 20 Dec 2019'
时间: 2023-11-21 20:52:40 浏览: 6912
这个错误是因为你的ssl模块是用OpenSSL 1.0.2u编译的,而新版本的urllib3需要OpenSSL 1.1.1+以上版本。解决这个问题的方法有两种:
1.升级OpenSSL到1.1.1+以上版本,然后重新编译ssl模块。
2.降级urllib3到1.x版本,这些版本不需要OpenSSL 1.1.1+以上版本。
如果你选择第一种方法,你可以按照以下步骤操作:
1.下载OpenSSL 1.1.1+以上版本的源代码。
2.解压缩源代码并进入源代码目录。
3.运行以下命令编译和安装OpenSSL:
./config
make
make install
4.重新编译ssl模块。
如果你选择第二种方法,你可以运行以下命令降级urllib3:
pip install urllib3==1.x
相关问题
运行完:yum install openssl-devel后,还是报错:ImportError: urllib3 v2.0 only supports OpenSSL 1.1.1+, currently the 'ssl' module is compiled with OpenSSL 1.0.2k-fips
这个错误提示是因为你的 Python 安装的是 OpenSSL 1.0.2k,而 urllib3 v2.0 需要使用 OpenSSL 1.1.1 或更高版本。你需要更新 OpenSSL 版本,然后重新编译 Python。
你可以按照以下步骤更新 OpenSSL:
1. 下载 OpenSSL 1.1.1 的源代码:
```
wget https://www.openssl.org/source/openssl-1.1.1l.tar.gz
```
2. 解压缩源代码包:
```
tar -zxvf openssl-1.1.1l.tar.gz
```
3. 进入源代码目录,配置和编译 OpenSSL:
```
cd openssl-1.1.1l
./config shared --prefix=/usr/local/ssl --openssldir=/usr/local/ssl
make
make install
```
4. 更新 ld.so.conf 配置文件:
```
echo "/usr/local/ssl/lib" >> /etc/ld.so.conf
ldconfig
```
5. 设置环境变量:
```
export LD_LIBRARY_PATH=/usr/local/ssl/lib:$LD_LIBRARY_PATH
```
完成以上步骤后,重新编译 Python,然后再运行程序即可。
怎么解决ImportError: urllib3 v2.0 only supports OpenSSL 1.1.1+, currently the 'ssl' module is compiled with OpenSSL 1.0.2p 14 Aug 2018. See: https://github.com/urllib3/urllib3/issues/2168
你可以尝试以下几种方法来解决这个问题:
1. 升级 OpenSSL 到 1.1.1 或以上版本。
2. 降级 urllib3 版本,可以通过以下命令降级到 1.25.10 版本:
```
pip install urllib3==1.25.10
```
3. 编译安装 Python,使用 OpenSSL 1.1.1 或以上版本,然后重新安装 urllib3。
```
./configure --with-openssl=/path/to/openssl
make
make install
```
注意:这种方法需要重新编译安装 Python,比较麻烦。
希望以上方法能够帮助你解决问题。