Codex ignores VSCode selected Python interpreter / virtual environment

Open 💬 4 comments Opened May 20, 2026 by magnetix-cgn

What version of the IDE extension are you using?

26.513.21555

What subscription do you have?

ChatGPT Plus

Which IDE are you using?

Visual Studio Code

What platform is your computer?

Linux chaosframe 6.x x86_64 GNU/Linux

What issue are you seeing?

Codex appears to ignore the Python interpreter selected in VSCode and instead uses the system Python interpreter.

Expected behavior:
When selecting a project-local virtual environment via:

Python: Select Interpreter

for example:

./xvx-venv/bin/python

Codex should inherit and use that interpreter/environment.

Observed behavior:
Codex uses:

/usr/bin/python

instead of the selected venv interpreter.

What steps can reproduce the bug?

Reproduction steps:

Create a project-local virtual environment:
python3 -m venv xvx-venv
Select the interpreter in VSCode:
./xvx-venv/bin/python
Open Codex inside VSCode
Ask Codex:
which python

Result:
/usr/bin/python

What is the expected behavior?

./xvx-venv/bin/python

Additional information

For any questions: magnetix@xvx-systems.de

View original on GitHub ↗

4 Comments

magnetix-cgn · 3 months ago

Seems to be valid only for Copilot not Codex, please check maybe I have to create a Copilot issue

scarpma · 3 months ago

I also agree with this issue and that is not about copilot, but the codex extension for vscode

magnetix-cgn · 3 months ago

quick fix - workaround: please adapt to your settings

add to AGENTS.md
Always run Python commands in this repository with the existing project virtualenv:

xvx-venv/bin/python

Do not create a second Python environment for this workspace unless explicitly requeste

Keesan12 · 3 months ago

This feels easier to debug if startup emits one tiny interpreter receipt somewhere visible in diagnostics or /status, for example:

{ python_executable, sys_prefix, venv_root, interpreter_source, cwd }

Where interpreter_source is something like selected_interpreter | workspace_default | system_fallback.

That would make it obvious whether Codex lost VS Code's selected interpreter before the agent starts, versus inheriting it correctly and drifting later.

The AGENTS.md workaround is useful for now, but I think the real fix is making the interpreter decision inspectable at the moment the session boots. If helpful, I'm happy to pressure-test a tiny receipt shape against venv, uv, and pyenv edge cases.