Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 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?

like image 966
NicoBar Avatar asked Jul 12 '18 14:07

NicoBar


People also ask

How do I move from one Python version to another?

Yes, you should be able to switch between python versions. As a standard, it is recommended to use the python3 command or python3. 7 to select a specific version. The py.exe launcher will automatically select the most recent version of Python you've installed.

How do I upgrade to a newer version of Python?

All you have to do is visit the Python downloads page and download the latest version. Clicking on the button will replace the existing version of Python with the new version. The older version will be removed from your computer. After you restart the computer, the new patch will be installed on your machine.


4 Answers

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.

like image 93
Prof. Jayanth R Varma Avatar answered Oct 22 '22 03:10

Prof. Jayanth R Varma


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

pip3.6 list | awk '{print $1}' | xargs -I{} pip3.7 install {}
like image 24
Tianyi Shi Avatar answered Oct 22 '22 04:10

Tianyi Shi


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 
like image 31
KavithaV Avatar answered Oct 22 '22 04:10

KavithaV


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*
like image 35
Smriti Singh Avatar answered Oct 22 '22 04:10

Smriti Singh