Python – Installing a clean Python 2.6 on SuSE (SLES) 11 using system-wide libraries

64-bitArchitecturepythonsles11

I've spent most of the day on this, and it is driving me absolutely insane. On all other Unixes I've used, this is a walk in the park, but SLES 11 has me dumbfounded.

I need to build Zope on SLES 11 64 bit:

Linux <name> 2.6.27.45-0.1-default #1 SMP 2010-02-22 16:49:47 +0100 x86_64 x86_64 x86_64 GNU/Linux

I first tried to just use the YaST-installed Python 2.6. I've also installed python-devel, libjpeg-devel, readline-devel, libopenssl-devel, libz2-devel, zlib-devel, and libgcrypt-devel.

The global python2.6 has a lot of cruft in it, and seems to execute stuff in /etc/pythonstart when I use it, which doesn't help. However, the error I get is this:

Getting distribution for 'Zope2==2.12.3'.
src/AccessControl/cAccessControl.c:596: warning: initialization from incompatible pointer type
src/AccessControl/cAccessControl.c:598: warning: ‘intargfunc’ is deprecated
src/AccessControl/cAccessControl.c:598: warning: initialization from incompatible pointer type
src/AccessControl/cAccessControl.c:599: warning: ‘intargfunc’ is deprecated
src/AccessControl/cAccessControl.c:599: warning: initialization from incompatible pointer type
src/AccessControl/cAccessControl.c:600: warning: ‘intintargfunc’ is deprecated
src/AccessControl/cAccessControl.c:600: warning: initialization from incompatible pointer type
src/AccessControl/cAccessControl.c:601: warning: initialization from incompatible pointer type
src/AccessControl/cAccessControl.c:602: warning: initialization from incompatible pointer type
src/AccessControl/cAccessControl.c:606: warning: ‘intargfunc’ is deprecated
src/AccessControl/cAccessControl.c:606: warning: initialization from incompatible pointer type
/usr/lib64/gcc/x86_64-suse-linux/4.3/../../../../x86_64-suse-linux/bin/ld: skipping incompatible /usr/lib/libpython2.6.so when searching for -lpython2.6
/usr/lib64/gcc/x86_64-suse-linux/4.3/../../../../x86_64-suse-linux/bin/ld: cannot find -lpython2.6
collect2: ld returned 1 exit status
error: Setup script exited with error: command 'gcc' failed with exit status 1
An error occured when trying to install Zope2 2.12.3. Look above this message for any errors that were output by easy_install.

I don't know what "incompatible" is referring to here; my guess would be the hardware architecture, but I'm not sure what's incompatible with what in the statement above.

I've had problems with system-installed Pythons before, so I tried to compile my own (hence the list of -devel packages above), downloading the Python 2.6 tarball and running:

./configure --disable-tk --prefix=${HOME}/python
make
make install

This installs, but it seems to be unable to find any system-wide libraries. Here's a sample interpreter session:

Python 2.6.5 (r265:79063, Mar 29 2010, 17:04:12) 
[GCC 4.3.2 [gcc-4_3-branch revision 141291]] on linux2
Type "help", "copyright", "credits" or "license" for more information.
Traceback (most recent call last):
  File "/etc/pythonstart", line 7, in <module>
    import readline
ImportError: No module named readline
>>> from hashlib import md5
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/osc/python-2.6/lib/python2.6/hashlib.py", line 136, in <module>
    md5 = __get_builtin_constructor('md5')
  File "/home/osc/python-2.6/lib/python2.6/hashlib.py", line 63, in __get_builtin_constructor
    import _md5
ImportError: No module named _md5

Both readline and hashlib (via libgrypt) should be installed, and the relevant -devel packages are also installed. On Ubuntu or OS X, this works just fine. On SuSE, no luck.

Any help greatly appreciated!

Martin

Best Answer

After an awful lot of pain, the missing piece was this: /usr/lib64/libpython2.6.so was missing. It should be a symlink to /usr/lib64/libpython2.6.so.1.0, but somehow it got lost or was never installed.

A custom-built python still failed to find certain libraries (e.g. libgcrypto or libopenssl), but I managed to get a good python using the SuSE-provided one, coupled with virtualenv --no-site-packages to get a pristine environment.

Thanks to all those who helped, especially Wichert on IRC who explained the .so symlink thing. ;-)

Related Topic