Skip to content

Codex ignores VSCode selected Python interpreter / virtual environment #23642

Open

Description

@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: [email protected]

Activity

  1. added
    extension
    on May 20, 2026
  2. added
    bug
    on May 20, 2026
  3. magnetix-cgn commented on May 21, 2026

    @magnetix-cgn
    Author

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

  4. scarpma commented on May 22, 2026

    @scarpma

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

  5. magnetix-cgn commented on May 22, 2026

    @magnetix-cgn
    Author

    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

  6. Keesan12 commented on May 22, 2026

    @Keesan12

    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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugextension

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions