You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Use custom devcontainer images with unexpected python instalations #329
The uv setup relies on the standard devcontainer image which comes with the repo. If attempting to switch image, the default uv integration fails.
Resolved by clearing existing uv setup and installing fresh, then using $ uv venv --seed --system-site-packages to create the venv. Run programs with $ uv run python /workspaces/path_to_file/file.py.
Correct about removing .python-version, though I believe this is only required if you want to use a different python version, rather than just re-configuring uv.
Using the suggested uv venv --seed --system-site-packages && prompts the user to explicitly clear existing .venv's upon container creation, adding the '--clear' flag makes this automatic.
I'm now using "postCreateCommand": "cd /workspaces/deltabot_nn_controller && uv venv --seed --system-site-packages --clear && pip install pre-commit && pre-commit install --install-hooks"
I believe you will then need to run the file as uv run python /workspaces/path_to_file/file.py instead of just python /workspaces/path_to_file/file.py if you'd like to use the new .venv.
There's some other bits and pieces I needed to do for my exact use case (different image, use system packages, expose CUDA), so there's possibly some entanglement between that and a minimal setup.
I believe you will then need to run the file as uv run python /workspaces/path_to_file/file.py instead of just python /workspaces/path_to_file/file.py if you'd like to use the new .venv.
Activity
coretl commentedon Mar 2, 2026
So the only things I imagine you need to do are:
uvis installed in the container in some way.python-versionas you want to follow the version of python installed on the system, not pin it in the repouv venv --seed --system-site-packages &&to the start of thepostCreateCommandpython /workspaces/path_to_file/file.pyDoes that work for you? If so this can be expanded into a how-to guide
DiamondRC commentedon Mar 2, 2026
Correct about removing
.python-version, though I believe this is only required if you want to use a different python version, rather than just re-configuring uv.Using the suggested
uv venv --seed --system-site-packages &&prompts the user to explicitly clear existing .venv's upon container creation, adding the '--clear' flag makes this automatic.I'm now using
"postCreateCommand": "cd /workspaces/deltabot_nn_controller && uv venv --seed --system-site-packages --clear && pip install pre-commit && pre-commit install --install-hooks"I believe you will then need to run the file as
uv run python /workspaces/path_to_file/file.pyinstead of justpython /workspaces/path_to_file/file.pyif you'd like to use the new .venv.There's some other bits and pieces I needed to do for my exact use case (different image, use system packages, expose CUDA), so there's possibly some entanglement between that and a minimal setup.
coretl commentedon Mar 2, 2026
But we already set the path here:
python-copier-template/.devcontainer/devcontainer.json
Line 19 in dc6564e
DiamondRC commentedon Mar 2, 2026
I think you're right, I have
"PATH": "${containerEnv:PATH}:/usr/local/cuda/bin",at the moment to detect the CUDA libraries.