Error installing Openai - aiohttps error on python 3.12

Hey everyone,

I seem to be getting an error when trying to install openai library in python. please see the terminal log below. I have tried cache purges and then doing manual aiohttp version installs for versions 3.8.1 through 3.8.6, but to no avail. I see in this log there is something about deprecated cython, so I am wondering if I need to do something else. I am using python 3.12

LOG

pip install --upgrade openai
Collecting openai
Downloading openai-0.28.1-py3-none-any.whl.metadata (11 kB)
Collecting requests>=2.20 (from openai)
Downloading requests-2.31.0-py3-none-any.whl.metadata (4.6 kB)
Collecting tqdm (from openai)
Downloading tqdm-4.66.1-py3-none-any.whl.metadata (57 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 57.6/57.6 kB 65.9 kB/s eta 0:00:00
Collecting aiohttp (from openai)
Downloading aiohttp-3.8.6.tar.gz (7.4 MB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 7.4/7.4 MB 1.6 MB/s eta 0:00:00
Installing build dependencies … done
Getting requirements to build wheel … done
Installing backend dependencies … done
Preparing metadata (pyproject.toml) … done
Collecting charset-normalizer<4,>=2 (from requests>=2.20->openai)
Downloading charset_normalizer-3.3.1-cp312-cp312-macosx_10_9_x86_64.whl.metadata (33 kB)
Collecting idna<4,>=2.5 (from requests>=2.20->openai)
Downloading idna-3.4-py3-none-any.whl (61 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 61.5/61.5 kB 646.2 kB/s eta 0:00:00
Collecting urllib3<3,>=1.21.1 (from requests>=2.20->openai)
Downloading urllib3-2.0.7-py3-none-any.whl.metadata (6.6 kB)
Collecting certifi>=2017.4.17 (from requests>=2.20->openai)
Downloading certifi-2023.7.22-py3-none-any.whl.metadata (2.2 kB)
Collecting attrs>=17.3.0 (from aiohttp->openai)
Downloading attrs-23.1.0-py3-none-any.whl (61 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 61.2/61.2 kB 587.7 kB/s eta 0:00:00
Collecting multidict<7.0,>=4.5 (from aiohttp->openai)
Downloading multidict-6.0.4.tar.gz (51 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 51.3/51.3 kB 6.7 MB/s eta 0:00:00
Installing build dependencies … done
Getting requirements to build wheel … done
Installing backend dependencies … done
Preparing metadata (pyproject.toml) … done
Collecting async-timeout<5.0,>=4.0.0a3 (from aiohttp->openai)
Downloading async_timeout-4.0.3-py3-none-any.whl.metadata (4.2 kB)
Collecting yarl<2.0,>=1.0 (from aiohttp->openai)
Downloading yarl-1.9.2.tar.gz (184 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 184.7/184.7 kB 553.5 kB/s eta 0:00:00
Installing build dependencies … done
Getting requirements to build wheel … done
Preparing metadata (pyproject.toml) … done
Collecting frozenlist>=1.1.1 (from aiohttp->openai)
Downloading frozenlist-1.4.0.tar.gz (90 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 90.7/90.7 kB 630.7 kB/s eta 0:00:00
Installing build dependencies … done
Getting requirements to build wheel … done
Preparing metadata (pyproject.toml) … done
Collecting aiosignal>=1.1.2 (from aiohttp->openai)
Downloading aiosignal-1.3.1-py3-none-any.whl (7.6 kB)
Downloading openai-0.28.1-py3-none-any.whl (76 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 77.0/77.0 kB 1.8 MB/s eta 0:00:00
Downloading requests-2.31.0-py3-none-any.whl (62 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 62.6/62.6 kB 640.6 kB/s eta 0:00:00
Downloading tqdm-4.66.1-py3-none-any.whl (78 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 78.3/78.3 kB 753.2 kB/s eta 0:00:00
Downloading async_timeout-4.0.3-py3-none-any.whl (5.7 kB)
Downloading certifi-2023.7.22-py3-none-any.whl (158 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 158.3/158.3 kB 691.2 kB/s eta 0:00:00
Downloading charset_normalizer-3.3.1-cp312-cp312-macosx_10_9_x86_64.whl (119 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 119.9/119.9 kB 196.1 kB/s eta 0:00:00
Downloading urllib3-2.0.7-py3-none-any.whl (124 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 124.2/124.2 kB 811.8 kB/s eta 0:00:00
Building wheels for collected packages: aiohttp, frozenlist, multidict, yarl
Building wheel for aiohttp (pyproject.toml) … error
error: subprocess-exited-with-error

× Building wheel for aiohttp (pyproject.toml) did not run successfully.
│ exit code: 1
╰─> [188 lines of output]
*********************
* Accelerated build *
*********************
running bdist_wheel
running build
running build_py
creating build
creating build/lib.macosx-10.9-universal2-cpython-312
creating build/lib.macosx-10.9-universal2-cpython-312/aiohttp
copying aiohttp/web_ws.py → build/lib.macosx-10.9-universal2-cpython-312/aiohttp
copying aiohttp/worker.py → build/lib.macosx-10.9-universal2-cpython-312/aiohttp
copying aiohttp/multipart.py → build/lib.macosx-10.9-universal2-cpython-312/aiohttp
copying aiohttp/web_response.py → build/lib.macosx-10.9-universal2-cpython-312/aiohttp
copying aiohttp/client_ws.py → build/lib.macosx-10.9-universal2-cpython-312/aiohttp
copying aiohttp/test_utils.py → build/lib.macosx-10.9-universal2-cpython-312/aiohttp
copying aiohttp/tracing.py → build/lib.macosx-10.9-universal2-cpython-312/aiohttp
copying aiohttp/web_exceptions.py → build/lib.macosx-10.9-universal2-cpython-312/aiohttp
copying aiohttp/web_middlewares.py → build/lib.macosx-10.9-universal2-cpython-312/aiohttp
copying aiohttp/web.py → build/lib.macosx-10.9-universal2-cpython-312/aiohttp
copying aiohttp/http_exceptions.py → build/lib.macosx-10.9-universal2-cpython-312/aiohttp
copying aiohttp/web_app.py → build/lib.macosx-10.9-universal2-cpython-312/aiohttp
copying aiohttp/streams.py → build/lib.macosx-10.9-universal2-cpython-312/aiohttp
copying aiohttp/web_protocol.py → build/lib.macosx-10.9-universal2-cpython-312/aiohttp
copying aiohttp/log.py → build/lib.macosx-10.9-universal2-cpython-312/aiohttp
copying aiohttp/client.py → build/lib.macosx-10.9-universal2-cpython-312/aiohttp
copying aiohttp/web_urldispatcher.py → build/lib.macosx-10.9-universal2-cpython-312/aiohttp
copying aiohttp/web_request.py → build/lib.macosx-10.9-universal2-cpython-312/aiohttp
copying aiohttp/http_websocket.py → build/lib.macosx-10.9-universal2-cpython-312/aiohttp
copying aiohttp/client_proto.py → build/lib.macosx-10.9-universal2-cpython-312/aiohttp
copying aiohttp/locks.py → build/lib.macosx-10.9-universal2-cpython-312/aiohttp
copying aiohttp/init.py → build/lib.macosx-10.9-universal2-cpython-312/aiohttp
copying aiohttp/web_runner.py → build/lib.macosx-10.9-universal2-cpython-312/aiohttp
copying aiohttp/web_server.py → build/lib.macosx-10.9-universal2-cpython-312/aiohttp
copying aiohttp/base_protocol.py → build/lib.macosx-10.9-universal2-cpython-312/aiohttp
copying aiohttp/payload.py → build/lib.macosx-10.9-universal2-cpython-312/aiohttp
copying aiohttp/client_reqrep.py → build/lib.macosx-10.9-universal2-cpython-312/aiohttp
copying aiohttp/http.py → build/lib.macosx-10.9-universal2-cpython-312/aiohttp
copying aiohttp/web_log.py → build/lib.macosx-10.9-universal2-cpython-312/aiohttp
copying aiohttp/resolver.py → build/lib.macosx-10.9-universal2-cpython-312/aiohttp
copying aiohttp/formdata.py → build/lib.macosx-10.9-universal2-cpython-312/aiohttp
copying aiohttp/payload_streamer.py → build/lib.macosx-10.9-universal2-cpython-312/aiohttp
copying aiohttp/web_routedef.py → build/lib.macosx-10.9-universal2-cpython-312/aiohttp
copying aiohttp/connector.py → build/lib.macosx-10.9-universal2-cpython-312/aiohttp
copying aiohttp/client_exceptions.py → build/lib.macosx-10.9-universal2-cpython-312/aiohttp
copying aiohttp/typedefs.py → build/lib.macosx-10.9-universal2-cpython-312/aiohttp
copying aiohttp/hdrs.py → build/lib.macosx-10.9-universal2-cpython-312/aiohttp
copying aiohttp/web_fileresponse.py → build/lib.macosx-10.9-universal2-cpython-312/aiohttp
copying aiohttp/http_writer.py → build/lib.macosx-10.9-universal2-cpython-312/aiohttp
copying aiohttp/tcp_helpers.py → build/lib.macosx-10.9-universal2-cpython-312/aiohttp
copying aiohttp/helpers.py → build/lib.macosx-10.9-universal2-cpython-312/aiohttp
copying aiohttp/http_parser.py → build/lib.macosx-10.9-universal2-cpython-312/aiohttp
copying aiohttp/cookiejar.py → build/lib.macosx-10.9-universal2-cpython-312/aiohttp
copying aiohttp/pytest_plugin.py → build/lib.macosx-10.9-universal2-cpython-312/aiohttp
copying aiohttp/abc.py → build/lib.macosx-10.9-universal2-cpython-312/aiohttp
running egg_info
writing aiohttp.egg-info/PKG-INFO
writing dependency_links to aiohttp.egg-info/dependency_links.txt
writing requirements to aiohttp.egg-info/requires.txt
writing top-level names to aiohttp.egg-info/top_level.txt
reading manifest file ‘aiohttp.egg-info/SOURCES.txt’
reading manifest template ‘MANIFEST.in’
warning: no files found matching ‘aiohttp’ anywhere in distribution
warning: no previously-included files matching ‘.pyc’ found anywhere in distribution
warning: no previously-included files matching '
.pyd’ found anywhere in distribution
warning: no previously-included files matching ‘.so’ found anywhere in distribution
warning: no previously-included files matching '
.lib’ found anywhere in distribution
warning: no previously-included files matching ‘.dll’ found anywhere in distribution
warning: no previously-included files matching '
.a’ found anywhere in distribution
warning: no previously-included files matching ‘.obj’ found anywhere in distribution
warning: no previously-included files found matching 'aiohttp/
.html’
no previously-included directories found matching ‘docs/_build’
adding license file ‘LICENSE.txt’
writing manifest file ‘aiohttp.egg-info/SOURCES.txt’
copying aiohttp/_cparser.pxd → build/lib.macosx-10.9-universal2-cpython-312/aiohttp
copying aiohttp/_find_header.pxd → build/lib.macosx-10.9-universal2-cpython-312/aiohttp
copying aiohttp/_headers.pxi → build/lib.macosx-10.9-universal2-cpython-312/aiohttp
copying aiohttp/_helpers.pyi → build/lib.macosx-10.9-universal2-cpython-312/aiohttp
copying aiohttp/_helpers.pyx → build/lib.macosx-10.9-universal2-cpython-312/aiohttp
copying aiohttp/_http_parser.pyx → build/lib.macosx-10.9-universal2-cpython-312/aiohttp
copying aiohttp/_http_writer.pyx → build/lib.macosx-10.9-universal2-cpython-312/aiohttp
copying aiohttp/_websocket.pyx → build/lib.macosx-10.9-universal2-cpython-312/aiohttp
copying aiohttp/py.typed → build/lib.macosx-10.9-universal2-cpython-312/aiohttp
creating build/lib.macosx-10.9-universal2-cpython-312/aiohttp/.hash
copying aiohttp/.hash/_cparser.pxd.hash → build/lib.macosx-10.9-universal2-cpython-312/aiohttp/.hash
copying aiohttp/.hash/_find_header.pxd.hash → build/lib.macosx-10.9-universal2-cpython-312/aiohttp/.hash
copying aiohttp/.hash/_helpers.pyi.hash → build/lib.macosx-10.9-universal2-cpython-312/aiohttp/.hash
copying aiohttp/.hash/_helpers.pyx.hash → build/lib.macosx-10.9-universal2-cpython-312/aiohttp/.hash
copying aiohttp/.hash/_http_parser.pyx.hash → build/lib.macosx-10.9-universal2-cpython-312/aiohttp/.hash
copying aiohttp/.hash/_http_writer.pyx.hash → build/lib.macosx-10.9-universal2-cpython-312/aiohttp/.hash
copying aiohttp/.hash/_websocket.pyx.hash → build/lib.macosx-10.9-universal2-cpython-312/aiohttp/.hash
copying aiohttp/.hash/hdrs.py.hash → build/lib.macosx-10.9-universal2-cpython-312/aiohttp/.hash
running build_ext
building ‘aiohttp._websocket’ extension
creating build/temp.macosx-10.9-universal2-cpython-312
creating build/temp.macosx-10.9-universal2-cpython-312/aiohttp
clang -fno-strict-overflow -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -O3 -Wall -arch arm64 -arch x86_64 -g -I/Users/travislueth/PycharmProjects/ChatGPT/chatgpt/include -I/Library/Frameworks/Python.framework/Versions/3.12/include/python3.12 -c aiohttp/_websocket.c -o build/temp.macosx-10.9-universal2-cpython-312/aiohttp/_websocket.o
aiohttp/_websocket.c:1475:17: warning: ‘Py_OptimizeFlag’ is deprecated [-Wdeprecated-declarations]
if (unlikely(!Py_OptimizeFlag)) {
^
/Library/Frameworks/Python.framework/Versions/3.12/include/python3.12/cpython/pydebug.h:13:1: note: ‘Py_OptimizeFlag’ has been explicitly marked deprecated here
Py_DEPRECATED(3.12) PyAPI_DATA(int) Py_OptimizeFlag;
^
/Library/Frameworks/Python.framework/Versions/3.12/include/python3.12/pyport.h:317:54: note: expanded from macro ‘Py_DEPRECATED’
#define Py_DEPRECATED(VERSION_UNUSED) attribute((deprecated))
^
aiohttp/_websocket.c:2680:27: warning: ‘ma_version_tag’ is deprecated [-Wdeprecated-declarations]
return likely(dict) ? __PYX_GET_DICT_VERSION(dict) : 0;
^
aiohttp/_websocket.c:1118:65: note: expanded from macro ‘__PYX_GET_DICT_VERSION’
#define __PYX_GET_DICT_VERSION(dict) (((PyDictObject*)(dict))->ma_version_tag)
^
/Library/Frameworks/Python.framework/Versions/3.12/include/python3.12/cpython/dictobject.h:22:5: note: ‘ma_version_tag’ has been explicitly marked deprecated here
Py_DEPRECATED(3.12) uint64_t ma_version_tag;
^
/Library/Frameworks/Python.framework/Versions/3.12/include/python3.12/pyport.h:317:54: note: expanded from macro ‘Py_DEPRECATED’
#define Py_DEPRECATED(VERSION_UNUSED) attribute((deprecated))
^
aiohttp/_websocket.c:2692:36: warning: ‘ma_version_tag’ is deprecated [-Wdeprecated-declarations]
return (dictptr && dictptr) ? __PYX_GET_DICT_VERSION(dictptr) : 0;
^
aiohttp/_websocket.c:1118:65: note: expanded from macro ‘__PYX_GET_DICT_VERSION’
#define __PYX_GET_DICT_VERSION(dict) (((PyDictObject
)(dict))->ma_version_tag)
^
/Library/Frameworks/Python.framework/Versions/3.12/include/python3.12/cpython/dictobject.h:22:5: note: ‘ma_version_tag’ has been explicitly marked deprecated here
Py_DEPRECATED(3.12) uint64_t ma_version_tag;
^
/Library/Frameworks/Python.framework/Versions/3.12/include/python3.12/pyport.h:317:54: note: expanded from macro ‘Py_DEPRECATED’
#define Py_DEPRECATED(VERSION_UNUSED) attribute((deprecated))
^
aiohttp/_websocket.c:2696:56: warning: ‘ma_version_tag’ is deprecated [-Wdeprecated-declarations]
if (unlikely(!dict) || unlikely(tp_dict_version != __PYX_GET_DICT_VERSION(dict)))
^
aiohttp/_websocket.c:1118:65: note: expanded from macro ‘__PYX_GET_DICT_VERSION’
#define __PYX_GET_DICT_VERSION(dict) (((PyDictObject
)(dict))->ma_version_tag)
^
/Library/Frameworks/Python.framework/Versions/3.12/include/python3.12/cpython/dictobject.h:22:5: note: ‘ma_version_tag’ has been explicitly marked deprecated here
Py_DEPRECATED(3.12) uint64_t ma_version_tag;
^
/Library/Frameworks/Python.framework/Versions/3.12/include/python3.12/pyport.h:317:54: note: expanded from macro ‘Py_DEPRECATED’
#define Py_DEPRECATED(VERSION_UNUSED) attribute((deprecated))
^
aiohttp/_websocket.c:2741:9: warning: ‘ma_version_tag’ is deprecated [-Wdeprecated-declarations]
__PYX_PY_DICT_LOOKUP_IF_MODIFIED(
^
aiohttp/_websocket.c:1125:16: note: expanded from macro ‘__PYX_PY_DICT_LOOKUP_IF_MODIFIED’
if (likely(__PYX_GET_DICT_VERSION(DICT) == __pyx_dict_version)) {
^
aiohttp/_websocket.c:1118:65: note: expanded from macro ‘__PYX_GET_DICT_VERSION’
#define __PYX_GET_DICT_VERSION(dict) (((PyDictObject*)(dict))->ma_version_tag)
^
/Library/Frameworks/Python.framework/Versions/3.12/include/python3.12/cpython/dictobject.h:22:5: note: ‘ma_version_tag’ has been explicitly marked deprecated here
Py_DEPRECATED(3.12) uint64_t ma_version_tag;
^
/Library/Frameworks/Python.framework/Versions/3.12/include/python3.12/pyport.h:317:54: note: expanded from macro ‘Py_DEPRECATED’
#define Py_DEPRECATED(VERSION_UNUSED) attribute((deprecated))
^
aiohttp/_websocket.c:2741:9: warning: ‘ma_version_tag’ is deprecated [-Wdeprecated-declarations]
__PYX_PY_DICT_LOOKUP_IF_MODIFIED(
^
aiohttp/_websocket.c:1129:30: note: expanded from macro ‘__PYX_PY_DICT_LOOKUP_IF_MODIFIED’
__pyx_dict_version = __PYX_GET_DICT_VERSION(DICT);
^
aiohttp/_websocket.c:1118:65: note: expanded from macro ‘__PYX_GET_DICT_VERSION’
#define __PYX_GET_DICT_VERSION(dict) (((PyDictObject*)(dict))->ma_version_tag)
^
/Library/Frameworks/Python.framework/Versions/3.12/include/python3.12/cpython/dictobject.h:22:5: note: ‘ma_version_tag’ has been explicitly marked deprecated here
Py_DEPRECATED(3.12) uint64_t ma_version_tag;
^
/Library/Frameworks/Python.framework/Versions/3.12/include/python3.12/pyport.h:317:54: note: expanded from macro ‘Py_DEPRECATED’
#define Py_DEPRECATED(VERSION_UNUSED) attribute((deprecated))
^
aiohttp/_websocket.c:3042:55: error: no member named ‘ob_digit’ in ‘struct _longobject’
const digit* digits = ((PyLongObject*)x)->ob_digit;
~~~~~~~~~~~~~~~~~~ ^
aiohttp/_websocket.c:3097:55: error: no member named ‘ob_digit’ in ‘struct _longobject’
const digit* digits = ((PyLongObject*)x)->ob_digit;
~~~~~~~~~~~~~~~~~~ ^
aiohttp/_websocket.c:3238:55: error: no member named ‘ob_digit’ in ‘struct _longobject’
const digit* digits = ((PyLongObject*)x)->ob_digit;
~~~~~~~~~~~~~~~~~~ ^
aiohttp/_websocket.c:3293:55: error: no member named ‘ob_digit’ in ‘struct _longobject’
const digit* digits = ((PyLongObject*)x)->ob_digit;
~~~~~~~~~~~~~~~~~~ ^
aiohttp/_websocket.c:3744:47: error: no member named ‘ob_digit’ in ‘struct _longobject’
const digit* digits = ((PyLongObject*)b)->ob_digit;
~~~~~~~~~~~~~~~~~~ ^
6 warnings and 5 errors generated.
error: command ‘/usr/bin/clang’ failed with exit code 1
[end of output]

note: This error originates from a subprocess, and is likely not a problem with pip.
ERROR: Failed building wheel for aiohttp
Building wheel for frozenlist (pyproject.toml) … done
Created wheel for frozenlist: filename=frozenlist-1.4.0-cp312-cp312-macosx_10_9_universal2.whl size=84986 sha256=b8c60a74ddeeb0888
Stored in directory: /Users/trav/Library/Caches/pip/wheels/f1/9c/94/93cb0ea511a9322645
Building wheel for multidict (pyproject.toml) … done
Created wheel for multidict: filename=multidict-6.0.4-cp312-cp312-macosx_10_9_universal2.whl size=48165 sha256=afc44decbaa44b06dad96
Stored in directory: /Users/trav/Library/Caches/pip/wheels/f6/d8/ff/3c14a64b8f2ab4ba28988be6ab446e5c8d1a82da
Building wheel for yarl (pyproject.toml) … done
Created wheel for yarl: filename=yarl-1.9.2-cp312-cp312-macosx_10_9_universal2.whl size=98522 sha256=66feda1a1cbdef60e24215208
Stored in directory: /Users/trav/Library/Caches/pip/wheels/84/e3/6a/7d0fabee8e43
Successfully built frozenlist multidict yarl
Failed to build aiohttp
ERROR: Could not build wheels for aiohttp, which is required to install pyproject.toml-based projects

I’d try to do a very exhaustive “uninstall” and then reinstall everything from scratch at the latest version, because with all those deprecation warnings I’d bet it’s a version incompatibility somewhere.

thank you for your response. When you say “Uninstall” are you refering to my python instance or certain libraries. I ask because I technically don’t have the openAI installed at this point.

I’m not enough of a python expert (I’m mainly a Java guy) to know how/where it caches libraries, etc. But you can google (or ask ChatGPT) how to be sure you’ve uninstalled all the libs. I know enough to at least mention “Conda”. A lot of people use conda to manage Python an it’s libs. It might be a good way to go.

Do you have any reason to be using 3.12? Unless you are developing libraries for it, no.

3.8-3.10

that did it. Just changed the interpreter to a version of 3.10 and the issue was resolved. Thank you.

try to install python 11.6 you can install openai without any ploblem

Same case, new venv with 3.10 fixes it. Curious though - 3.12 is a month old now.

For Python 3.12

https://stackoverflow.com/questions/77388920/warning-c4996-py-optimizeflag-deprecated-in-3-12-aiohttp-websocket-c3042/77388956#77388956

As this topic has a selected solution, closing topic.