## TL;DR

Install openai 0.27.0 or later into the Python interpreter you are actually running, then restart the kernel or IDE: pip install --upgrade openai Then: in Jupyter/VS Code, restart the kernel; in PyCharm, install openai 0.27.0+ through the interpreter's package manager and restart.

## Steps

1. This is almost always a stale install shadowing the new package, not a bug in the library. Install openai 0.27.0 or later into the Python interpreter you are actually running, then restart the kernel or IDE:

2. pip install --upgrade openai

3. Then: in Jupyter/VS Code, restart the kernel; in PyCharm, install openai 0.27.0+ through the interpreter's package manager and restart. Also do not name your own script `openai.py`, since Python will import that instead of the package. The maintainer's advice: if in doubt, create a fresh virtualenv and install there, which multiple users confirmed works.

## When to use

You are seeing this: Issue openai/openai-python#246 (closed, 27 comments): ### Describe the bug The feature was working few hours ago, now it's giving error. Use this skill when you run into "AttributeError: module 'openai' has no attribute 'ChatCompletion'".

## When not to use

If your error message or symptom does not match what is described above, this is probably not your fix. Search for your exact error text instead of forcing this one to fit.

## Versions

Versions mentioned in the source: openai 0.27.0. If you are on something much newer or older, the details may have shifted.

## Why this happens

The original report does not dig into a root cause. It documents the symptom and the fix that resolved it.

## Edge cases

- Also do not name your own script openai.py, since Python will import that instead of the package.
