Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I am trying to install Python2.7 on cr-48 chromebook in developer mode, and face a weird issue that I am having hard time searching for a solution on google. First some background.. the root partition is mounted readonly, so I have been installing packages under /usr/local, which is a separate mount point that is writable. There is a way to force root partition itself readwrite (with some minor disadvantages), but I decided not to go that route. I have been downloading archlinux packages and extract them under /usr/local and several of them have been working great so far. I basically extract the .tar.xz file somewhat like this:

xz -dc package.tar.xz | sudo tar --strip-components=1 -C /usr/local -xvf -

This basically drops the files destined for /usr to be under /usr/local instead. I export /usr/local/lib ahead of /usr/lib under the LD_LIBRARY_PATH, and got several packages to work fine this way. For some reason, python fails to load recognize this, though not completely sure what causes it. After expanding python 2.7 package which I got from archlinux site, I was able to start the python shell fine, and a simple print worked fine. I then tried to install setuptools, so downloaded the source from pypy and tried running sudo /usr/local/python2 setup.py install, but it kept giving me the below error:

/usr/local/bin/python2: error while loading shared libraries: libpython2.7.so.1.0: cannot open shared object file: No such file or directory

The libpython2.7.so.1.0 file is in deed there in /usr/local/lib/ directory which is there in LD_LIBRARY_PATH. A quick run of ldd shows this clearly:

chronos@localhost /tmp/setuptools-1.1.6 $ ldd /usr/local/bin/python2
        linux-gate.so.1 (0x777a9000)
        libpython2.7.so.1.0 => /usr/local/lib/libpython2.7.so.1.0 (0x77610000)
        libpthread.so.0 => /lib/libpthread.so.0 (0x775ee000)
        libc.so.6 => /lib/libc.so.6 (0x77464000)
        libdl.so.2 => /lib/libdl.so.2 (0x77460000)
        libutil.so.1 => /lib/libutil.so.1 (0x7745b000)
        libm.so.6 => /lib/libm.so.6 (0x77436000)
        /lib/ld-linux.so.2 (0x777aa000)

I also checked /etc/ld.so.conf and that too has /usr/local/lib:

chronos@localhost /tmp/setuptools-1.1.6 $ cat /etc/ld.so.conf 
# ld.so.conf autogenerated by env-update; make all changes to
# contents of /etc/env.d directory
/lib
/usr/lib
/usr/local/lib
/usr/lib/opengl/xorg-x11/lib

I installed strace (and perl since it is listed as a dependent), and ran the install command under strace which shows the below interesting output (see that it is NOT looking for /usr/local/lib/libpython2.7.so.1.0 anywhere):

chronos@localhost /tmp/setuptools-1.1.6 $ sudo strace /usr/local/bin/python2 setup.py installPassword: 
execve("/usr/local/bin/python2", ["/usr/local/bin/python2", "setup.py", "install"], [/* 16 vars */]) = 0
brk(0)                                  = 0x9b3c000
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x776e6000
access("/etc/ld.so.preload", R_OK)      = -1 ENOENT (No such file or directory)
open("/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3
fstat64(3, {st_mode=S_IFREG|0644, st_size=37049, ...}) = 0
mmap2(NULL, 37049, PROT_READ, MAP_PRIVATE, 3, 0) = 0x776dc000
close(3)                                = 0
open("/lib/tls/i686/sse2/libpython2.7.so.1.0", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat64("/lib/tls/i686/sse2", 0x7fd88d90) = -1 ENOENT (No such file or directory)
open("/lib/tls/i686/libpython2.7.so.1.0", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat64("/lib/tls/i686", 0x7fd88d90)     = -1 ENOENT (No such file or directory)
open("/lib/tls/sse2/libpython2.7.so.1.0", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat64("/lib/tls/sse2", 0x7fd88d90)     = -1 ENOENT (No such file or directory)
open("/lib/tls/libpython2.7.so.1.0", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat64("/lib/tls", 0x7fd88d90)          = -1 ENOENT (No such file or directory)
open("/lib/i686/sse2/libpython2.7.so.1.0", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat64("/lib/i686/sse2", 0x7fd88d90)    = -1 ENOENT (No such file or directory)
open("/lib/i686/libpython2.7.so.1.0", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat64("/lib/i686", 0x7fd88d90)         = -1 ENOENT (No such file or directory)
open("/lib/sse2/libpython2.7.so.1.0", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat64("/lib/sse2", 0x7fd88d90)         = -1 ENOENT (No such file or directory)
open("/lib/libpython2.7.so.1.0", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat64("/lib", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
open("/usr/lib/tls/i686/sse2/libpython2.7.so.1.0", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat64("/usr/lib/tls/i686/sse2", 0x7fd88d90) = -1 ENOENT (No such file or directory)
open("/usr/lib/tls/i686/libpython2.7.so.1.0", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat64("/usr/lib/tls/i686", 0x7fd88d90) = -1 ENOENT (No such file or directory)
open("/usr/lib/tls/sse2/libpython2.7.so.1.0", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat64("/usr/lib/tls/sse2", 0x7fd88d90) = -1 ENOENT (No such file or directory)
open("/usr/lib/tls/libpython2.7.so.1.0", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat64("/usr/lib/tls", 0x7fd88d90)      = -1 ENOENT (No such file or directory)
open("/usr/lib/i686/sse2/libpython2.7.so.1.0", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat64("/usr/lib/i686/sse2", 0x7fd88d90) = -1 ENOENT (No such file or directory)
open("/usr/lib/i686/libpython2.7.so.1.0", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat64("/usr/lib/i686", 0x7fd88d90)     = -1 ENOENT (No such file or directory)
open("/usr/lib/sse2/libpython2.7.so.1.0", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat64("/usr/lib/sse2", 0x7fd88d90)     = -1 ENOENT (No such file or directory)
open("/usr/lib/libpython2.7.so.1.0", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat64("/usr/lib", {st_mode=S_IFDIR|0755, st_size=20480, ...}) = 0
writev(2, [{"/usr/local/bin/python2", 22}, {": ", 2}, {"error while loading shared libra"..., 36}, {": ", 2}, {"libpython2.7.so.1.0", 19}, {": ", 2}, {"cannot open shared object file", 30}, {": ", 2}, {"No such file or directory", 25}, {"\n", 1}], 10/usr/local/bin/python2: error while loading shared libraries: libpython2.7.so.1.0: cannot open shared object file: No such file or directory
) = 141
exit_group(127)                         = ?
+++ exited with 127 +++

I have always gotten custom installation paths to work by just including the lib path in LD_LIBRARY_PATH and exporting it, so not sure what else I could be missing here. Any help is much appreciated.

share|improve this question

migrated from serverfault.com Oct 30 '13 at 10:15

This question came from our site for system and network administrators.

    
I think you need to, somehow, make setup.py search all that libpython*.so* files prefixed with your /usr/local/... path. Use find to get existing paths to libpython2.7.* and then invoke setup.py --help and look for prefix options. –  galegosimpatico Oct 30 '13 at 11:08
    
Is the output of /usr/local/bin/python2 -c 'import os;print(os.getenv("LD_LIBRARY_PATH"))' what you expect? –  rickhg12hs Nov 22 '13 at 1:19
1  
Yes, returns what is exported. –  haridsv Nov 23 '13 at 3:55

1 Answer 1

In addition to LD_LIBRARY_PATH, you probably need to set some Python specific environment variables, like, PYTHONHOME & PYTHONPATH. See the Python man page for the details.

After installing new libraries, you may also need to run ldconfig as root to update the library cache file.

Another option to try is to set environment variable RUN_LD_PATH or maybe even use -rpath or -rpath-link compiler/linker options.

You might also try to prelink all your executables and libraries under /usr/local, although this may be tedious since the directories probably are not listed in /etc/prelink.conf. Maybe just start with your python executable.

share|improve this answer
    
Good guess! I tried setting export PYTHONHOME=/usr/local/ and export PYTHONPATH=/usr/local/lib/python2.7/ but it didn't help :( –  haridsv Nov 7 '13 at 15:50
    
Does 'sudo echo $LD_LIBRARY_PATH' output what you expect? –  rickhg12hs Nov 7 '13 at 19:59
    
Yes, it outputs the same value as in the current interactive shell. –  haridsv Nov 21 '13 at 4:13
    
@haridsv See updated answer for something else to try. –  rickhg12hs Nov 21 '13 at 8:46
1  
Yes, since python won't even start. –  haridsv Nov 23 '13 at 14:28

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.