I'm trying to create a devcontainer.json that will create a Python virtual environment and activate it in the terminal immediately.
I use postCreateCommand to create the environment, and that seems to work:
"postCreateCommand": "python3 -m venv .venv",
But I haven't figured out how to get the terminal to always activate it. I've tried adding this setting:
"settings": {
"python.terminal.activateEnvInCurrentTerminal": true
}
As well as post*Commands:
"postAttachCommand": ". .venv/bin/activate",
"postStartCommand": ". .venv/bin/activate",
"postCreateCommand": ". .venv/bin/activate",
They don't seem to reliably activate it. I think postAttachCommand
worked sometimes, but not always.