Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the proper way to update Python packages when updating Python from 2.6 to 2.7?

I've installed A LOT of python packages for Python 2.6. Now I would like to upgrade Python to 2.7. Is there a proper or systematic way to update all the installed packages?

In my system, all the packages are installed at /usr/lib64/python2.6/site-packages/ and /usr/lib/python2.6/site-packages/

One obvious way is to install Python 2.7, download all the package sources or egg files, and re-install them one by one. However, Some useful packages like numpy and scipy are notorious for installation, especially when one needs to install from source. I expect I'll need to spend several hours to find the packages and solve the installation problems here and there.

Anyone has any suggestions on systematically update the installed packages?

like image 207
user1036719 Avatar asked Jul 25 '12 15:07

user1036719


People also ask

How can I upgrade Python with pip?

Ensure you can run pip from the command lineRun python get-pip.py . 2 This will install or upgrade pip. Additionally, it will install setuptools and wheel if they're not installed already.


1 Answers

First, you should not never ever ever ever install Python packages in in system library folder with easy_install using sudo on any operating system.

http://jamiecurle.co.uk/blog/installing-pip-virtualenv-and-virtualenvwrapper-on-os-x/#comment-573429347

The correct procedure would be make your installation procedure repeatable. There exist two commonly used solutions in Python world. These solutions automatically download correct versions of Python packages from http://pypi.python.org

PIP

pip and requirements.txt http://www.pip-installer.org/en/latest/requirements.html within virtualenv http://pypi.python.org/pypi/virtualenv

Buidout

Buildout, example from Plone CMS https://github.com/plone/Installers-UnifiedInstaller/blob/master/base_skeleton/versions.cfg

Buildout can also do configure, make, make install style installations for packages which need native libraries. For example there exist solution for libxml2 + lxml

http://pypi.python.org/pypi/z3c.recipe.staticlxml/

(Note: buildout does not need virtualenv as it does its own isolation from system Python)

like image 178
Mikko Ohtamaa Avatar answered Sep 24 '22 02:09

Mikko Ohtamaa