Austin Weisgrau
11/07/2025, 12:48 AMuv for a prefect AWS ECS push pool, do we need to modify the entrypoint command to ensure that the correct executable is used at runtime? I didn't modify the entrypoint command but now the execution at runtime seems to be in the wrong python environmentMarvin
11/07/2025, 12:48 AMAustin Weisgrau
11/07/2025, 12:50 AMAustin Weisgrau
11/07/2025, 12:55 AMpython -m prefect.engine to uv run python -m prefect.engineMarvin
11/07/2025, 12:56 AMFROM prefecthq/prefect:3-latest
# Add uv
COPY --from=<http://ghcr.io/astral-sh/uv:latest|ghcr.io/astral-sh/uv:latest> /uv /usr/local/bin/uv
# Install into system Python
ENV UV_SYSTEM_PYTHON=1
COPY requirements.txt .
RUN uv pip install --system -r requirements.txt
2) Use a dedicated venv and put it first on PATH
- No shell activation required; the right python is picked up by PATH.
FROM prefecthq/prefect:3-latest
# Optional: install uv
COPY --from=<http://ghcr.io/astral-sh/uv:latest|ghcr.io/astral-sh/uv:latest> /uv /usr/local/bin/uv
# Create venv and ensure it’s first on PATH
RUN python -m venv /opt/venv
ENV PATH="/opt/venv/bin:${PATH}"
# Install dependencies into that venv
COPY requirements.txt .
RUN uv pip install -r requirements.txt
# or: RUN pip install -r requirements.txt
3) If you must activate a venv via ENTRYPOINT
- Keep ENTRYPOINT minimal and “exec”-based so Prefect’s command is passed through.
- ECS push pools typically override CMD/command, not ENTRYPOINT. Your ENTRYPOINT can activate and then exec "$@".
Example:
# entrypoint.sh
#!/usr/bin/env sh
. /opt/venv/bin/activate
exec "$@"
# Dockerfile
COPY entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh
ENTRYPOINT ["/entrypoint.sh"]
Quick checks to confirm at runtime
Add a tiny debug at the start of your flow to confirm the interpreter that’s running:
import sys, prefect
print("Python:", sys.executable)
print("Prefect:", prefect.__version__)
If it does not point to your intended env, fix PATH or switch to UV_SYSTEM_PYTHON.
A couple of gotchas with uv
- uvx is great for ad-hoc commands, but it resolves environments on the fly. For containers, prefer a stable install (UV_SYSTEM_PYTHON=1 or an explicit venv on PATH).
- If you rely on uv-managed cached envs without adjusting PATH, ECS won’t “activate” them and you’ll see missing imports at runtime.
If you can share your Dockerfile (base image, how you install uv and deps, and whether you set ENTRYPOINT), I can pinpoint the minimal change for your setup.
Relevant docs
- ECS guide: Prefect AWS ECS guide
- Serverless/push infra overview: Serverless (push) infrastructureAustin Weisgrau
11/07/2025, 12:58 AMAustin Weisgrau
11/07/2025, 12:59 AM