AttributeError: module 'openai' has no attribute 'ChatCompletion'
Describe the bug
Hello.
I cant access gpt-3.5-turbo with python because I seem to be getting the error " AttributeError: module ‘openai’ has no attribute ‘ChatCompletion’"
I have updated to openai v0.27.0, as well as tried using new API keys just incase that was causing the issue. Ive double checked that I actually have updated to the new version of openai 0.27.0 by running “pip list”. Ive also tried " pip install --upgrade openai " and “pip install openai-0.27.0-py3-none-any.whl”
Im not sure what else I can try, does anyone have any ideas? Thanks.
To Reproduce
import os import openai openai.api_key = os.getenv("key")
completion = openai.ChatCompletion.create( model="gpt-3.5-turbo", messages=[ {"role": "user", "content": "Hello!"} ] )
print(completion.choices[0].message)
Code snippets
No response
OS
macOS
Python version
Python v3.11.2
Library version
openai 0.27.0
this issue is occurring for version v0.26.5, Upgrade to v0.27.0
Tried

Working on v0.27.0

I am using v0.27.0, here is a screenshot of the output for "pip show openai"

I can confirm, I'm having the same issue. I'm using poetry for dependency management and it says I have v0.27.0 installed but still getting the AttributeError.
I just fixed the issue by creating a new virtual environment and reinstalling all my dependencies inside the new environment.
In your case, @emilycowe, I suggest going to your site-packages directory and deleting the openai folder(s), and then running the pip install command again.
Yeah, sorry about this folks, it is a dependency management issue which Python makes harder than it has to be. If you create a new virtual env, you should be fine. I am closing this for now but the guidance is to make a new virtual env.
yea a simple. "pip uninstall openai"....then "pip install openai" inside the virtual environment fixed my issue. Easy day!