I've just upgraded to Ubuntu 20.04. I was working with a python 3.7 project using Django inside a virtual environment, so I was confident even with the upgraded distro (which involved the installation of python 3.8) my venv would still worked. Unfortunately, that's not the case: when I activate my venv, the interpreter of python is still the 3.8 version, and nothing works. python 3.7 is completely missing. What can I do to restore my project?
Asked
Active
Viewed 6,231 times
11
-
after **python3 -m venv --upgrade venv/ ** and manually reinstalling each python module, it works. Now, my git repo is stil referenced to the old python version, are there any precautions I have to use in order to not miss my repo? Theoretically, on github there aren't direct references to virtual environment, so it should be transparent to the python version used. Am I wrong? – dc_Bita98 May 01 '20 at 12:01
-
Not sure about what you are asking. But I think it is often helpful to consider virtual environments as throwaway things. Do not hesitate to delete them and create new ones as soon as something changes. The right tooling helps facilitate that. The first thing would be to curate precise list of dependencies, for example with `requirements.txt` files. Moving from one version of the Python interpreter to another one should be painless. – sinoroc May 01 '20 at 13:28
-
@sinoroc following your indications, I've just delete the **venv** folder and recreate it. Then installed the required modules in `requirements.txt` and everything works fine. I was just afraid of missing something – dc_Bita98 May 01 '20 at 13:40
2 Answers
3
Same problem for me. This is my solution if you do not want to upgrade everything (perhaps not all package are upgradable).
Install python 3.7 which is gone with upgrade to ubuntu 20
sudo add-apt-repository ppa:deadsnakes/ppa sudo apt-get update sudo apt-get install python3.7
in your virtualenv dir (e.g env/) edit last line in pyenv.cfg
version = 3.7
set back soft link of python3 in env/bin linking back to 3.7
ln -s /usr/bin/python3.7 python3
You may need to delete old symlik before creating new one
Now, should work: it does for me!
1
In my case, it was solved just by deleting and recreating the virtual env, and reinstalling Django, of course. After that, just reloaded Apache and everything worked again.

Erich Georg
- 11
- 1