Skip to content Skip to sidebar Skip to footer

How To Move All Modules To New Version Of Python (from 3.6 To 3.7)

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

Solution 1:

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.


Solution 2:

It is safer to re-install all packages due to possible compatibility issues:

pip3.6 list | awk '{print $1}' | xargs -I{} pip3.7 install {}

Solution 3:

in older version of Python --run the command

pip freeze > requirments.txt

download and install newer version on python.. change the PATH variable to the new version and run the command

pip install -r requirments.txt 

Solution 4:

In some cases, we don't have the opportunity to pip freeze in old version--because I've already updated and old version have been purged! There are some measures I've taken to recover some of the packages but I'm NOT sure every package would work with this fix.(e.g. the packages built with wheels)

  1. mv /your/path/to/python3.{6,7}/site-packages/
  2. If the case is packages installed outside venv (in /usr/local/ or ~/.local), reinstall pip with get-pip.py, just to be safe.
  3. If you are recovering a virtualenv. Activate your virtualenv and use my script

Most of your packages should work by now. If anything malfunctions, pip reinstall would works. If you still want it 100% works, pip freeze now.😉


Solution 5:

I'm not sure about all modules...but if you want to install a module specifically in python3.7, try this:

python3.7 -m pip install *module_name*

Post a Comment for "How To Move All Modules To New Version Of Python (from 3.6 To 3.7)"