Hello guys, I have some questions on how Python virtual environment (python -m venv
) works in docker containers.
Context
- On my local openSUSE machine, I have an already created virtual environment
.venv
underworkspace
directory. - I use VSCode’s Dev Container to open
workspace
in a Tensorflow container, andworkspace
is mounted in the container. - When I activate
.venv
from the container, Python will not use the packages in.venv
. It seems that Python is still using system-wide packages. I checked this by runningpip3 list --local
when.venv
was activated, and it gave a result that is exactly the same as when.venv
is not activated. - When I create a new virtual environment under
workspace
from the container, it works and Python will use the packages in the new virtual environment. - Python version is 10 on the local machine, and 8 in the container.
Question
So why is Python in the container still using system-wide packages when the virtual environment (that is created on the local machine) is activated? Is this related to how Python is configured in the Tensorflow container?