dcfg
dcfg

Reputation: 891

python 3.7 venv broken after upgrade to Ubuntu 20.04

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?

Upvotes: 11

Views: 7607

Answers (3)

churcht
churcht

Reputation: 41

When this happened to me, rather than delete venv, I moved it to venv.broken, then installed the new venv. The advantage (for me) in doing it this way was when it came to installing the requirements. I subsequently found out that my requirements.txt was missing some important packages. By examining the site_packages directory in venv.broken it was possible to figure out what was missing.

Upvotes: 2

Joff
Joff

Reputation: 56

Same problem for me. This is my solution if you do not want to upgrade everything (perhaps not all package are upgradable).

  1. 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
    
  2. in your virtualenv dir (e.g env/) edit last line in pyenv.cfg

    version = 3.7
    
  3. 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!

Upvotes: 4

Erich Georg
Erich Georg

Reputation: 11

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.

Upvotes: 1

Related Questions