Missing core Python modules in your Plone buildout?

by Rudd-O published 2012/07/21 20:55:00 GMT+0, last modified 2013-06-26T03:24:22+00:00
Sometimes when you install Plone, the installer will not compile certain modules during the Python compilation stage, simply because the development packages are not available. Here's how to fix that.

The problem manifests itself with error tracebacks attempting to import certain Plone eggs that require core Python functionality, which may or may not be available on your system.  We'll use the quintessential bpython example:

bin/debugclient debug
Starting debugger (the name "app" is bound to the top-level Zope object)
2012-07-21 13:31:54 WARNING SecurityInfo Conflicting security declarations for "setText"
2012-07-21 13:31:54 WARNING SecurityInfo Class "ATTopic" had conflicting security declarations
2012-07-21 13:31:59 WARNING Init Class Products.Five.metaclass.RedirectsView has a security declaration for nonexistent method 'errors'
>>> import bpython
>>> bpython.embed(locals_=locals())
Traceback (most recent call last):
  File "", line 1, in 
  File "/home/rudd-o/tmp/localplone/plonedevelwithbpython/buildout-cache/eggs/bpython-0.11-py2.6.egg/bpython/__init__.py", line 30, in embed
    from bpython.cli import main
  File "/home/rudd-o/tmp/localplone/plonedevelwithbpython/buildout-cache/eggs/bpython-0.11-py2.6.egg/bpython/cli.py", line 47, in 
    import curses
  File "/opt/plonezeo/Python-2.6/lib/python2.6/curses/__init__.py", line 15, in 
    from _curses import *
ImportError: No module named _curses

In this example, Python is telling us that its built-in curses module is not really built -- only the Python wrappers are available.

Naturally, this renders the use of the (amazing) bpython module for Zope unusable.

How to fix it

I'm assuming that you don't want to redo everything on your Plone deployment.  So here's how you go about redoing this:

  1. Install the pertinent development packages you need to build the binary modules.  In this case, it would be ncurses-devel.
  2. Download the same Plone installer version that you used to deploy your Plone deployment.
  3. Uncompress the tarball, and change into the created directory.
  4. Run the installer (./install.sh) with the following parameters:
    ./install.sh --target=/some/temporary/path/you/must/create none
  5. That's it.  You now have a new Python inside the path /some/temporary/path/you/must/create.  Next step is up.
  6. Synchronize your newly-created Python environment with the Plone development Python environment.
    rsync -av /some/temporary/path/you/must/create/Python*/ /path/to/your/plone/deployment/Python*/

Voilá.  You now have a Python inside your Plone deployment that has the requisite binary modules enabled.