Trouble with venv Auto Updating
Background
I used our system python3.7 install to create a virtual environment.
/bin/python3.7 -m venv ~/myvenv
I then activated the virtual environment with:
cd ~/myvenv && source bin/activate
I confirmed with which python3
that it was indeed using the venv (path lead to venv)
I installed my packages I needed
The software ran for months.
The Issue
Then our IT department added python3.9
to the OS, my python3.7 venv I had created made a python3.9 directory in ~/myenv/lib/python3.9
and altered altered all of my binaries in ~/myenv/bin
to the new python3.9. This also was using the new lib/python3.9 site packages.
All this stopped my program from running, as the new venv had no site-packages installed.
I was able to revert my venv back to 3.7 by deleting all the binaries in ~/myenv/bin
and running /bin/python3.7 -m venv ~/myvenv
again. My old site-packages were still in the lib/python3.7
folder in my venv.
Help
- Can anyone explain how this happened?
- Am I missing a fundamental detail with how you should setup virtual environments?
Tidbits and Thoughts
My IT claims they did not run --update
on my venv.
I can only imagine it must have something to do with paths. Is it also possible I used python3 -m venv ~/myenv
when I made the venv? Would that cause this to happen?
I would think not, I was under the impression the venv was a localized “clone” of the python version you invoke it with.
EDIT
The operating system in question is Solaris
EDIT 2 - SOLVED
Apparently I can’t read documentation (RTFM).
I must have used just python3
instead of /usr/bin/python
or /usr/python
and it used the symlink for python3. Per the documentation
It also creates a
bin
(orScripts
on Windows) subdirectory containing a copy/symlink of the Python binary/binaries (as appropriate for the platform or arguments used at environment creation time).