2023-05-22 urllib3 v2.0 only supports OpenSSL 1.1.1+, currently the 'ssl' module is compile

问题描述:

1, python 出错堆栈

Traceback (most recent call last):

  File "/Users/ly3/dev/bili/code/android/andruid/bbgit.py", line 8, in

    import requests

  File "/Users/ly3/Library/Python/3.9/lib/python/site-packages/requests/__init__.py", line 43, in

    import urllib3

  File "/Users/ly3/Library/Python/3.9/lib/python/site-packages/urllib3/__init__.py", line 38, in

    raise ImportError(

ImportError: urllib3 v2.0 only supports OpenSSL 1.1.1+, currently the 'ssl' module is compiled with LibreSSL 2.8.3. See: https://github.com/urllib3/urllib3/issues/2168

2, 查看本地openssl版本

>openssl  version

LibreSSL 3.3.6

3, urllib3版本

 % pip3 list urllib3

Package            Version

------------------ --------

altgraph          0.17.2

certifi            2023.5.7

charset-normalizer 3.1.0

future            0.18.2

idna              3.4

macholib          1.15.2

pip                23.1.2

requests          2.30.0

setuptools        58.0.4

six                1.15.0

urllib3            2.0.2

wheel              0.37.0

原因:

通过上述第三步查看urllib3 版本为 2.0.2,其依赖openssl 1.1.1+, 而本地的openssl为 LibreSSL 3.3.6,验证匹配不上导致报错。

解决方法:

urllib3为requests依赖引入,降低 requests版本

操作步骤:

pip3 install "requests==2.29.0"

再查看版本:

% pip3 list urllib3

Package            Version

------------------ --------

altgraph          0.17.2

certifi            2023.5.7

charset-normalizer 3.1.0

future            0.18.2

idna              3.4

macholib          1.15.2

pip                23.1.2

requests          2.29.0

setuptools        58.0.4

six                1.15.0

urllib3            1.26.15

wheel              0.37.0

看着urllib3已经低于 2.0

此时再执行原先python命令,就会通过。

你可能感兴趣的:(2023-05-22 urllib3 v2.0 only supports OpenSSL 1.1.1+, currently the 'ssl' module is compile)