Hi all,
I’ve run pip install openai
successfully.
I’m just trying to run a simple image gen running the following code copied and pasted perfectly from the OpenAI API page:
import os
import openai
openai.api_key = os.getenv("OPENAI_API_KEY")
openai.Image.create(
prompt="A cute baby sea otter",
n=2,
size="1024x1024"
)
and I get the following error:
ImportError: cannot import name 'Mapping' from 'collections' (C:\Users\The Best\AppData\Local\Programs\Python\Python310\lib\collections\__init__.py)
On Stack Overflow they recommend changing the import command, but the error is coming from within the OpenAI library.
Apparently I’m the only one on the internet experiencing this problem. Can someone kindly assist? I’m running Python 3.10.5 64-bit on Windows 10.
Thanks so much!
In case you need the full traceback:
Traceback (most recent call last):
File "c:\Users\The Best\thebest-1\gptfun.py", line 3, in <module>
import openai
File "C:\Users\The Best\AppData\Local\Programs\Python\Python310\lib\site-packages\openai\__init__.py", line 19, in <module>
from openai.api_resources import (
File "C:\Users\The Best\AppData\Local\Programs\Python\Python310\lib\site-packages\openai\api_resources\__init__.py", line 1, in <module>
from openai.api_resources.audio import Audio # noqa: F401
File "C:\Users\The Best\AppData\Local\Programs\Python\Python310\lib\site-packages\openai\api_resources\audio.py", line 4, in <module>
from openai import api_requestor, util
File "C:\Users\The Best\AppData\Local\Programs\Python\Python310\lib\site-packages\openai\api_requestor.py", line 25, in <module>
import requests
File "C:\Users\The Best\AppData\Local\Programs\Python\Python310\lib\site-packages\requests\__init__.py", line 43, in <module>
import urllib3
File "C:\Users\The Best\AppData\Local\Programs\Python\Python310\lib\site-packages\urllib3\__init__.py", line 8, in <module>
from .connectionpool import (
File "C:\Users\The Best\AppData\Local\Programs\Python\Python310\lib\site-packages\urllib3\connectionpool.py", line 29, in <module>
from .connection import (
File "C:\Users\The Best\AppData\Local\Programs\Python\Python310\lib\site-packages\urllib3\connection.py", line 39, in <module>
from .util.ssl_ import (
File "C:\Users\The Best\AppData\Local\Programs\Python\Python310\lib\site-packages\urllib3\util\__init__.py", line 3, in <module>
from .connection import is_connection_dropped
File "C:\Users\The Best\AppData\Local\Programs\Python\Python310\lib\site-packages\urllib3\util\connection.py", line 3, in <module>
from .wait import wait_for_read
File "C:\Users\The Best\AppData\Local\Programs\Python\Python310\lib\site-packages\urllib3\util\wait.py", line 1, in <module>
from .selectors import (
File "C:\Users\The Best\AppData\Local\Programs\Python\Python310\lib\site-packages\urllib3\util\selectors.py", line 14, in <module>
from collections import namedtuple, Mapping
ImportError: cannot import name 'Mapping' from 'collections' (C:\Users\The Best\AppData\Local\Programs\Python\Python310\lib\collections\__init__.py)