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

8,996

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. ;-)

Share:
8,996

Related videos on Youtube

optilude
Author by

optilude

Updated on September 17, 2022

Comments

  • optilude
    optilude almost 2 years

    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

    • optilude
      optilude about 14 years
      Another interesting note: I tried to build the egg directly (with python setup.py build_ext). The output is: building 'AccessControl.cAccessControl' extension gcc -pthread -shared build/temp.linux-x86_64-2.6/src/AccessControl/cAccessControl‌​.o -L/usr/lib64 -lpython2.6 -o build/lib.linux-x86_64-2.6/AccessControl/cAccessControl.so /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 Note the -L/usr/lib64 in there. Somehow, that makes gcc happy, but not ld.
  • optilude
    optilude about 14 years
    Thanks for the reply! It didn't work, though. The problem is not in getting somethign to link to a custom python lib, but rather to get C extensions to buid. The closest I've come is to do this: 0. Uninstall libpython-32bit, so there's no longer a /usr/lib/libpython2.6.so.1.0 (but there's one in /usr/lib64) 1. Create a --no-site-packages virtualenv 2. Use this python to do "python setup.py build_ext", which just builds the C extensions This still fails with: ld: cannot find -lpython2.6 as shown in more detail above.
  • optilude
    optilude about 14 years
    Yes, that may get me a sane python with readline; not sure about the md5 stuff, or openssl or other system-libraries it can't link to, though. :-/ And even then, I'm not convinced it'll build C extensions properly (see my comment above).
  • gareth_bowles
    gareth_bowles about 14 years
    +1 for including your answer