Home Artificial Intelligence Fixing ImportError: urllib3 v2.0 only supports OpenSSL 1.1.1+

Fixing ImportError: urllib3 v2.0 only supports OpenSSL 1.1.1+

1
Fixing ImportError: urllib3 v2.0 only supports OpenSSL 1.1.1+

Reproducing the error

First, let’s start by creating and activating a virtual environment that we shall be using with the intention to install some Python dependencies.

# Create a virtual environment
$ python3 -m venv ~/test-venv

# Activate our newly created virtual environment
$ source ~/test-venv/bin/activate

Now let’s install a few dependencies with pinned versions, that can help us reproduce the error that has probably brought you to this tutorial!

We then install openai package

$ pip install openai

And at last, let’s fan the flames of a Python interactive session and import openai:

Python 3.9.6 (default, Mar 10 2023, 20:16:38) 
[Clang 14.0.3 (clang-1403.0.22.14.1)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import openai

In case you are running Python 3.9, then likely you’ll find yourself getting the next error trace:

Traceback (most up-to-date call last):
File "", line 1, in
File "/Users/xmas/Library/Python/3.9/lib/python/site-packages/openai/__init__.py", line 19, in
from openai.api_resources import (
File "/Users/mic/Library/Python/3.9/lib/python/site-packages/openai/api_resources/__init__.py", line 1, in
from openai.api_resources.audio import Audio # noqa: F401
File "/Users/mic/Library/Python/3.9/lib/python/site-packages/openai/api_resources/audio.py", line 4, in
from openai import api_requestor, util
File "/Users/mic/Library/Python/3.9/lib/python/site-packages/openai/api_requestor.py", line 22, in
import requests
File "/Users/mic/Library/Python/3.9/lib/python/site-packages/requests/__init__.py", line 43, in
import urllib3
File "/Users/mic/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

1 COMMENT

LEAVE A REPLY

Please enter your comment!
Please enter your name here