How to move all modules to new version of Python (from 3.6 to 3.7)

NicoBar picture NicoBar · Jul 12, 2018 · Viewed 8.8k times · Source

I just upgraded to python 3.7 and I realized that all my modules stuck with the previous version. Even Django is not recognised anymore. How can I do to transfer everything to the new version? I am a little lost right now, don't even know where the new version has been installed.

Edit:

When I do $ which python3.6 the terminal tells me it doesn't exist, but I have a python3.6 directory in /usr/local/lib/, where all modules are installed.

In the same directory /usr/local/lib/ I also have a python3.7 directory with some modules installed but many are missing. However when I search for the file python3.7 in my finder it doesn't appear. when I do $ which python3.7 the path is /usr/local/bin so not the same path as the directory.

Anyone sees what happened and knows how I can transfer all modules to python3.7?

Answer

Prof. Jayanth R Varma picture Prof. Jayanth R Varma · Jan 6, 2020

Even if the old python version has been removed, it is possible to use the pip of the current python version with the --path option to list all the modules installed in the previous version.

For example, migrating all my user installed python modules from 3.7 to 3.8

pip freeze --path ~/.local/lib/python3.7/site-packages > requirements.txt
pip install --user -r requirements.txt

Incidentally, I always use pip install with --user and leave the system wide installations to the package manager of my linux distro.