Issues with Python Environment Activation in Codex Tasks (uv, .venv, poe, Python 3.12)

Description

I’m working in OpenAI Codex and having trouble getting my Python environment to behave consistently across the “Environments > Edit” preview and actual task execution. Below are the key details and symptoms:


:laptop: Environment Setup

  • Using Python 3.12
  • Environment defined in a Devcontainer
  • Project dependencies managed using:
    • pyproject.toml + uv for fast installs
    • poethepoet for CLI tasks
  • Two installation attempts:
    1. uv sync
    2. pip install .

:red_exclamation_mark:Problems Encountered

1. .venv disappears in Codex tasks
  • After uv sync, a .venv is created and visible in the “Environments > Edit” preview.
  • However, in a new Codex task, that .venv is not present anymore — resulting in failed imports or missing commands.
2. poe commands not found during execution
  • When installing with pip install ., my poe commands (e.g., poe lint) are available and listed in the preview.
  • But when running a Codex task like poe lint, it errors with:
bash: poe: command not found

→ Indicates that the actual task shell isn’t picking up the environment.

3. Wrong Python version when running tasks
  • Despite setting Python 3.12 explicitly and it showing correctly in “Environments > Edit”, a task asking for the Python version with:
python --version

Returns:

Python 3.11.12

→ Suggests either the environment isn’t being activated or an internal fallback is being used.


:magnifying_glass_tilted_left: What I Tried

  • Switching between uv sync and pip install .
  • Ensuring .venv is committed and available
  • Manually adding .venv/bin to $PATH via postCreateCommand
  • Confirming poe works inside the container manually, but not inside Codex tasks
  • Using "Use This" on the configured environment

:red_question_mark: My Questions

  • Any steps to activate the environment for tasks that I forgot to execute?
  • What’s the underlying cause to have the Python version mismatch and how to fix this?
  • How to properly build an environment based on uv in Codex?
  • Is there a way to enforce environment activation like source .venv/bin/activate? Adding this explicitly in the environment setup didn’t work either.

I assume issues like this would be resolved by allowing custom image uploads, but since that’s not yet possible, Codex is currently unusable for my work (:cry:).

1 Like

No problems here with py 3.13 here . Except for models writing code with syntax errors..