Updated Python; Do I need to manually reinstall all package sites?

I recently updated my Linux distribution. Python 3.5 has been superseded by Python 3.6.

All the site packages I installed with pip3

are still in the directory /usr/lib/python3.5/site-packages

and Python doesn't find them there now because it clearly looks in .../python3.6/site-packages

.

I can see the contents of the directory and I could manually install it again, but that doesn't look the right way to me. I could move the content to a new directory, but then again, this seems to be wrong too.

How should I handle it correctly?

Do I have to prepare a list pip3 freeze

before updating?

I tried searching, but the keywords are probably too general and got a lot of unrelated answers.

+3


source to share


2 answers


Python 3.5 has been superseded by Python 3.6. But you still have python 3.5 backup option.

If you want to use python 3.6, you will have to install all the python 3.6 packages again. And it makes sense.

Say you changed from 2.7 to 3.5. You would like to keep both environments separate. Therefore, environment 3.6 is different from 3.5.

A quick way to do this would be pip freeze

for 3.5 and then install those dependencies for 3.6.

pip freeze > reqs.txt

      

Update



pip install -r reqs.txt

      

Since you no longer have this option, please try first and list all packages in your python3.5

for this you can install pip3.5 as @kabanus answered.

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

      

It is also recommended to use a virtual environment for each project so that you can maintain separate environments for each one.

+1


source


This will make it easier for you to reinstall. Checkout description . Using freeze

, you could do something like:

$ env1/bin/pip3 freeze > requirements.txt
$ env2/bin/pip3 install -r requirements.txt

      

Generally, the recommended method is to use virtualenv

site- specific packages , so you don't put your installation scopes, but TBH never broke anything for me. Another option is to check if the Linux distribution has a package to search correctly, for example:

sudo apt-get install python3-<somemodule>

      



This is what I prefer - and could be updated by the distribution. As for what to do now, if you really don't want to reinstall everything correctly, you can give it a try cp /usr/lib/python3.5/site-packages/* /usr/lib/python3.6/site-packages

. The differences between the versions are not that great that I believe most packages will work right off the bat. You may need to sed

replace python3.5

with python3.6

in all files. Forget to delete all pyc

files if you do.

Python modules are self-contained enough that if something is broken it can be processed per package, and site packages are completely self-contained, so you can always just uninstall everything and reinstall.

One final note - you can try installing pyton3.5 / pip3.5 for your Linux and then freeze function. If the package is missing, you can manually install ( whl

or such) or compile the standalone interface and configure the site path correctly. If you want to keep the files in the global site package directory or navigate to virtualenv

, this might be the safest option.

+1


source







All Articles