libpython2.7.so.1.0: cannot open shared object file: No such file or directory

前端 未结 7 1427
Happy的楠姐
Happy的楠姐 2020-12-06 04:25

I have trying to run python script from the terminal but getting the next error message :

ImportError: libpython2.7.so.1.0: cannot open shared object file: N         


        
7条回答
  •  遥遥无期
    2020-12-06 04:56

    This isn't a subject I'm keen on, but my understanding is for Linux machines especially (where you're compiling python binaries) that shared library directories should be specified at the compile step.

    For instance, following the linked example, here is how I ensure libpython2.7.so.1.0 is included in addition to other libraries:

    ./configure --enable-shared \
            --prefix=/directory/for/Python-2.7.15 \
            LDFLAGS="-Wl,--rpath=/usr/local/lib -Wl,--rpath=/directory/for/Python-2.7.15"
    

    Notice I'm also installing python to a fixed directory of my choosing, via the --prefix option. That might not be necessary for you, but I did it to provide a solution for the general case where your python install might be located anywhere.

    With the above solution, I never have to export LD_LIBRARY_PATH or mess with ldconfig

提交回复
热议问题