How to control Python environment activation in a DevContainer in VS Code?

25 Views Asked by At

I am mounting the local file system to the container. I noticed that when opening a Terminal in a DevContainer mode, if there is a .venv directory in the default directory of the container, that environment gets activated. This is not desired due to two reasons:

  • This directory may be mapped from my local file system and cannot be reused in the container.
  • The current activation method is unknown and another environment activation method is preferred.

Regarding the second point, I see the command prompt beginning with (.venv), whereas poetry-activated environment must have a different prompt.

I am using poetry as a package manager. The best way to activate the environment is using poetry shell. Can I configure VSCode to:

  • Stop activating the environment in .venv (at least)?
  • Use custom activation technique such as running poetry shell?
0

There are 0 best solutions below