Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Upgraded Python; Do I have to reinstall all site-packages manually?

Tags:

I have upraded my Linux distro recently. Python 3.5 was replaced by Python 3.6.

All site packages I have installed with pip3 are still in the /usr/lib/python3.5/site-packages directory and Python does not find them there now, because it looks in .../python3.6/site-packages obviously.

I see the directory contents and I could manually install them again, but that does not look to me like the right way to do it. I could move the contents to the new directory, but again, this seems to me incorrect either.

How am I supposed to handle it properly?

Should I have prepared a pip3 freeze list before the upgrade?

I tried to search, but the keywords are probably too general and got many unrelated answers.

like image 589
VPfB Avatar asked Aug 08 '17 09:08

VPfB


People also ask

How do you update Python site packages?

Just execute it from anywhere using a Python interpreter whose packages you'd like to check (e.g., python3 check_for_updates.py or from within a virtualenv). You can then uses pip install -U <packagename> (or pip-3.2 for Python 3) to update the packages.

Can I install two versions of a Python package on the same computer?

easy_install allows simultaneous installation of different versions of the same project into a single environment shared by multiple programs which must require the appropriate version of the project at run time (using pkg_resources ).

Where does Python install site packages?

When a package is installed globally, it's made available to all users that log into the system. Typically, that means Python and all packages will get installed to a directory under /usr/local/bin/ for a Unix-based system, or \Program Files\ for Windows.


1 Answers

Python 3.5 was replaced by Python 3.6. But you still have the backup option of using python 3.5.

If you want to use python 3.6 you will have to reinstall all pip packages again for python 3.6. And it makes sense.

Say you were changing from 2.7 to 3.5. You would want to preserve both the environments separately. Hence 3.6 environment is different from 3.5.

A quick way to do this would be to pip freeze for 3.5 and then install those dependencies for 3.6.

pip freeze > reqs.txt

upgrade

pip install -r reqs.txt

Since you don't have this option anymore, first try and list all packages in your python3.5

for that you can install pip3.5 as answered by @kabanus.

sudo apt-get install python3=3.5.1*
sudo python3.5 easy_install.py pip

Also it's advised to use virtual environment per project so you can maintain separate environments for each of them.

like image 72
Vikash Singh Avatar answered Oct 24 '22 20:10

Vikash Singh