Contact Us

If you are interested in our services leave your contact details below and our sales representatives will contact you.

The organization which you represent
Email address we will use to contact you
Longer contact form…
 
  • About

    mFabrik Blog is about mobile and web software development, open source and Linux. We tell exciting tales where business, technology, web and mobile convergence.

    Creative Commons License
    This work is licensed under a Creative Commons Attribution 3.0 Unported License.

Easily install all Python versions under Linux and OSX using collective.buildout.python

Posted on July 16, 2010  by Mikko Ohtamaa
Filed Under plone, python, technology, ubuntu

Here are short instructions how to install all versions (2.4, 2.5, 2.6, 2.7 and 3.1) of Python interpreters on UNIX system. The instructions were tested on Ubuntu 10.04 Lucid Lynx Linux but should work on other systems as is. The installation is based of downloading, compiling and installing different Pythons and their libraries using buildout tool. A buildout configuration for doing this is maintained by a Plone community.

This buildout is especially useful to get Python 2.4 properly running under the latest Ubuntu 10.04 Lucid Lynx. This is because Ubuntu repositories won’t ship with Python 2.4 packages anymore.

The installation will also include static compilation of some very popular libraries. These are dependencies for other Python packages including, but not limited, to

  • libjpeg
  • Python imaging library
  • readline

Prerequisites

  • Some Python version is installed (OS default)
  • GCC compiler is installed (sudo apt-get install build-essential)
  • Subversion tool is installed (sudo apt-get install subversion)

Running it

svn co http://svn.plone.org/svn/collective/buildout/python/
cd python
python bootstrap.py
bin/buildout

Using it

All Pythons are under virtualenv installations. This means that you can activate one Python configuration for your shell once easily (python command will run under different Python versions).

Activating Python 2.4

source python/python-2.4/bin/activate
(python-2.4)moo@murskaamo:~/code$ python -V
Python 2.4.6

Check that Python Imaging Library works

python
Python 2.4.6 (#1, Jul 16 2010, 10:31:46)
[GCC 4.4.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import PIL

(No exceptions raised, Python Imaging Library works well).

Read our blog  Subscribe mFabrik blog in a reader Follow us on Twitter Mikko Ohtamaa on LinkedIn

 

Other posts by Mikko Ohtamaa

 

Comments

17 Responses to “Easily install all Python versions under Linux and OSX using collective.buildout.python”

  1. JeanMichel FRANCOIS aka toutpt on July 16th, 2010 11:43 am
    Gravatar

    http://minitage.org is able to do that about a year or two. You should try it and contact the author on #plone : kiorky

     
  2. Maurits van Rees on July 16th, 2010 12:36 pm
    Gravatar

    Note that to check if PIL is installed properly, you should also try ‘import _imaging’. If that fails, then Plone can start up, but when uploading a picture it will not be converted to the various sizes (thumbnail, preview, etc).

     
  3. kiorky on July 16th, 2010 12:53 pm
    Gravatar

    Hello, just a little correction, the minitage’s python can also support sqlite, bdb and all other python official extensions that canno’t be well supported if you don’t have installed the prerequisites on your system, system wide.

    The built python is also built with -rpath ensuring that you won’t have to play with LD_LIBRARY_PATH at runtime.

    But minitage also offers system isolation and project deployment consistency (among OSes and projects).

    As it is related to plone, among minitage, we, at makina also use collective.generic.* packages. The goal of thoses package is to deploy in an unique way our portals, no matter their underlying needs. You click & play in the web ront end, and it generates a portal tarball including the uber buildout, the policy & the theme which will do your project born.

    See http://pypi.python.org/pypi/collective.generic.webbuilder/.

     
  4. Steve Williams on July 17th, 2010 6:30 am
    Gravatar

    stevew@stevew-laptop:~/python$ python bootstrap.py
    Traceback (most recent call last):
    File “bootstrap.py”, line 113, in
    ws.find(pkg_resources.Requirement.parse(requirement)).location
    AttributeError: ‘NoneType’ object has no attribute ‘location’

     
  5. Mikko Ohtamaa on July 17th, 2010 1:49 pm
    Gravatar

    I think this is usually because Python setuptools (easy_install command) shipped with your OS is too old.

    Try this:

    easy_install -U setuptools # sudo if needed

     
  6. Mikko Ohtamaa on July 19th, 2010 4:07 pm
    Gravatar

    If you want to build Python on Linux using system libraries try this buildout instead:

    https://svn.plone.org/svn/collective/buildout/bda-naked-python/

    Here are some instructions:

    http://permalink.gmane.org/gmane.comp.web.zope.plone.product-developers/4966

     
  7. Brandon Thomson on July 21st, 2010 6:07 pm
    Gravatar

    This will also be useful for folks who need 2.5 for Google App Engine (it’s not in Lucid Lynx either)

     
  8. Russ Ferriday on July 27th, 2010 4:19 am
    Gravatar

    Re: ws.find bug: Fixed by Wichert: https://bugs.launchpad.net/zc.buildout/+bug/410528

    I hit same bug using bda-naked-python.

     
  9. Running 32-bit chroot on 64-bit Ubuntu server to reduce Python memory usage | mFabrik - web and mobile development on August 3rd, 2010 7:15 pm
    Gravatar

    [...] integration for Python and Plone CMSDebugging Skype crash problems on Ubuntu 10.04 Lucid Lynx LinuxEasily install all Python versions under Linux and OSX using collective.buildout.pythonChanging the location of Ubuntu 10.04 Lucid Lynx notification bubble to a different cornermFabrik to [...]

     
  10. Yuri on August 4th, 2010 3:43 pm
    Gravatar

    What about libxml2 dependencies of Marshaller? Can this way to install make it automatic?

     
  11. Mikko Ohtamaa on August 4th, 2010 3:50 pm
  12. Yuri on August 4th, 2010 4:06 pm
    Gravatar

    Thanks!

    I get:

    ~/PYTHON_VIRTUALENV/python/python-2.4# ./bin/python
    Python 2.4.6 (#1, Aug 4 2010, 14:42:18)
    [GCC 4.3.2] on linux2
    Type “help”, “copyright”, “credits” or “license” for more information.
    >>> import PIL
    >>> import _imaging
    Traceback (most recent call last):
    File “”, line 1, in ?
    ImportError: libjpeg.so.8: cannot open shared object file: No such file or directory
    >>>

    so I think something went wrong.

     
  13. Mikko Ohtamaa on August 4th, 2010 4:09 pm
  14. Yuri on August 4th, 2010 4:29 pm
    Gravatar

    ~/PYTHON_VIRTUALENV/python# find . | grep libjpeg.so
    ./python-2.4/lib/libjpeg.so.8.0.2
    ./python-2.4/lib/libjpeg.so.8
    ./python-2.4/lib/libjpeg.so
    ./python-2.5/lib/libjpeg.so.8.0.2
    ./python-2.5/lib/libjpeg.so.8
    ./python-2.5/lib/libjpeg.so
    ./python-2.6/lib/libjpeg.so.8.0.2
    ./python-2.6/lib/libjpeg.so.8
    ./python-2.6/lib/libjpeg.so
    ./parts/opt/lib/libjpeg.so.8.0.2
    ./parts/opt/lib/libjpeg.so.8
    ./parts/opt/lib/libjpeg.so

    so they are there.. now pypi is down and I cannot try any more :(

     
  15. higkoo on September 1st, 2010 5:59 am
    Gravatar

    Just Do This:
    echo ‘/usr/local/lib’ >> /etc/ld.so.conf

     
  16. Mikko Ohtamaa on September 1st, 2010 2:21 pm
    Gravatar

    Hi,

    Do you know any way to set LD_LIBRARY_PATH during the compilation time? So that buildout would work without changing your system or shell settings?

     
  17. kiorky on September 1st, 2010 10:54 pm
    Gravatar

    You can use -rpath to free you from using ld_library_path at runtime.
    See:
    - http://en.wikipedia.org/wiki/Rpath_%28linking%29
    - http://tldp.org/HOWTO/Program-Library-HOWTO/shared-libraries.html

    Basicly if you have something like this:
    - /bar/include/foo.h
    - /bar/lib/liba.so

    And your target installation path is “/foo”

    Do something like that:
    export CFLAGS=”$CFLAGS -I/bar/include”
    export LDFLAGS=”$LDFKAGS -Wl,-rpath -Wl,/foo -Wl,-rpath -Wl,/bar -L/bar”

    If you want to embed that with buildout, you can have a look to minitage.recipe.cmmi & minitage.recipe.common.

     

Leave a Reply