I get this error ModuleNotFoundError: No module named ‘agents’
when I attempt to import
from agents import Agent, Runner
openai-agents has been installed and listed in requirements.txt
Which API are you calling? completion?
It is new agents SDK. But all of a sudden it started finding the module. Don’t know why. Maybe a refresh of the requirements.txt did the trick. Idk
Thank you for responding
2 Likes
I’m getting the same err:
python 3.12.8 - windows
openai==1.66.3
openai-agents==0.0.3
Check the name or the directory that you’re using to define your project.
If you name it agents.py or agents you will precede the import from Python site-packages.
3 Likes
It’s also possible that you have an interpreter mismatch, which can happen if you’ve set up a virtual environment (venv)
- Make sure that the venv is activated
. .venv/bin/activate 2>/dev/null || source .venv/bin/activate
- Check the Python version inside the venv
python -V # e.g. Python 3.12.10
- Deactivate the venv and check global Python
deactivate - Compare the versions
- if they match, your interpreter is fine.
- if they differ, update your IDE setting:
- In Cursor/VS Code:
- Press ⌘⇧P
- Scroll down and select “Python: Interpreter”
- Choose the one pointing to your venv .venv/bin/python
- In Cursor/VS Code: