Codex doesn't activate Python environments
What version of Codex is running?
0.75.0
What subscription do you have?
Plus
Which model were you using?
GPT-5.2-Codex
What platform is your computer?
Microsoft Windows NT 10.0.26200.0 x64
What issue are you seeing?
Codex sometimes tries to execute some Python that imports installed packages. But this fails because it doesn't first activate the Python environment, so the imports don't resolve.
I don't know if this is fixable in the system prompt, or if it requires training. Either way it would be a nice touch.
What steps can reproduce the bug?
If you ask it to look at source, sometimes it will use rg but sometimes it will try to run Python.
One example, in the VS Code extension, and showing the Python error that appears:
<img width="1145" height="636" alt="Image" src="https://github.com/user-attachments/assets/56240051-247c-4165-ad96-fd38df3927ca" />
And this is despite me telling it about this issue:
<img width="1145" height="162" alt="Image" src="https://github.com/user-attachments/assets/2d582bea-1a48-4404-9515-cb1f9706b0ec" />
What is the expected behavior?
It should know that running the code it tried to run wouldn't work without activating the python environment. I don't know if the solution should be in regular code (e.g. check the current directory and if it looks like a Python project and it can find an activation script in the usual places, then run it). Or maybe the model should be trained to work this out for itself to use the project python executable if it exists, rather than the global one. Or maybe it should be a user configurable setting.
Additional information
FWIW the AI Assistant in PyCharm gets this right, I believe it activates the environment before making it available to the agent, allowing the agent to just use python and everything works.