Python3.7 venv auto adds Python3.9 when Python3.9 was added to the System

Trouble with venv Auto Updating


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.


  • 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.


The operating system in question is Solaris


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 (or Scripts on Windows) subdirectory containing a copy/symlink of the Python binary/binaries (as appropriate for the platform or arguments used at environment creation time).

Did your IT people “fix” your venv without telling you?

I know of nothing that would explain what happened.

1 Like

Updated my post (Edit2), apparently I can’t read the docs. The binaries in the venv bin directory for my OS are symlinks.

Oh yes symlinks… i was assuming that both 3.7 and 3.9 where installed side by side.
What you are saying the system python3 changed and the venv pointed to that symlink.


And I just learned from this experience that those are symlinks and not actual copies of the python executables/binaries.

Which makes me think I must have used the system path to python3 (i.e. just python3 instead of /usr/bin/python3 the absolute path) when installing these?

I wonder what venv does if you use python3.7 and not python3 as the program?