use*_*826 4 debian mod-wsgi compilation python-3.x
我正在尝试使用--enable-shared选项安装Python 3.安装"成功"但生成的Python不可运行.安装后尝试运行Python会出现以下错误:
$ /opt/python3/bin/python3.5
/opt/python3/bin/python3.5: error while loading shared libraries: libpython3.5m.so.1.0: cannot open shared object file: No such file or directory
Run Code Online (Sandbox Code Playgroud)
操作系统是Debian(squeeze),并且之前安装了Python 2.6,这是必须保留的,因为其他代码依赖于它,以及Apache 2.2.最终我要做的是设置Django在Apache上运行,这意味着我正在尝试安装mod_wsgi(或mod_wsgi-express),这需要共享库.我已经尝试安装mod_wsgi的,而不使用--enable-shared在Python安装,并且已经得到了...好,同样的事情,但这次从mod_wsgi的安装程序(和pip install mod_wsgi,我也试过)/opt/python3/bin/python3.5: error while loading shared libraries: libpython3.5m.so.1.0: cannot open shared object file: No such file or directory.
从上面背景中描述的安装开始,这里是我执行的产生上述错误的命令的最小列表(删除了详细程度).
user@server:~$ wget https://www.python.org/ftp/python/3.5.1/Python-3.5.1.tgz
user@server:~$ tar -zxvf Python-3.5.1.tgz
user@server:~$ cd Python-3.5.1
user@server:~/Python-3.5.1$ ./configure --prefix=/opt/python3 --enable-shared
user@server:~/Python-3.5.1$ make && sudo make install
(... appears to install correctly)
user@server:~/Python-3.5.1$ /opt/python3/bin/python3.5
/opt/python3/bin/python3.5: error while loading shared libraries: libpython3.5m.so.1.0: cannot open shared object file: No such file or directory
Run Code Online (Sandbox Code Playgroud)
我也尝试过这个问题,LD_RUN_PATH如解决其他问题所述,结果相同:
user@server:~/Python-3.5.1$ sudo make distclean
user@server:~/Python-3.5.1$ ./configure --prefix=/opt/python3 --enable-shared
user@server:~/Python-3.5.1$ LD_RUN_PATH=/usr/local/lib make
user@server:~/Python-3.5.1$ sudo make install
user@server:~/Python-3.5.1$ /opt/python3/bin/python3.5
/opt/python3/bin/python3.5: error while loading shared libraries: libpython3.5m.so.1.0: cannot open shared object file: No such file or directory
Run Code Online (Sandbox Code Playgroud)
我也尝试过使用Python 3.4,结果相同.我没有尝试使用Python 2,因为我不希望将来的开发仅限于Python 2.7(因此即使成功的安装也不能满足我的要求).我也假设尝试不会提供任何新的或有用的信息.
我注意到--enable-shared在pip install mod_wsgi安装python时没有出现文件夹/opt/python3/bin/python3.5: error while loading shared libraries: libpython3.5m.so.1.0: cannot open shared object file: No such file or directory,但是如果LD_RUN_PATH没有使用则会出现.我假设这是一个自然的后果--enable-shared.pip install mod_wsgi正如预期的那样,该文件夹已经存在.(新的共享安装是否可以尝试使用这些/opt/python3/bin/python3.5: error while loading shared libraries: libpython3.5m.so.1.0: cannot open shared object file: No such file or directory库?或者2.6文件夹的存在是否会干扰其他方式?)
我是一名软件程序员,被迫扮演系统管理员的角色,所以我的第一个猜测是有一些小的(模糊的?众所周知的?)细节我不了解安装如何在Linux上运行,或者Python库如何交互在操作系统级别上.我已经沉迷了大量时间,只是将问题缩小到Python安装,并试图找到解决方案.(所以,如果解决方案已经在线存在,请保持温和,并了解我确实看过!)
我猜这与这个悬而未决的问题有关吗?
也可能与扩展或构建环境有关?
我已经在CentOS7上重复了你的步骤并获得类似的东西:
$ /tmp/py3/bin/python3
/tmp/py3/bin/python3: error while loading shared libraries: libpython3.5m.so.1.0: cannot open shared object file: No such file or directory
Run Code Online (Sandbox Code Playgroud)
如果你看一下python的链接,它没有提供库的完整路径:
$ ldd /tmp/py3/bin/python3
linux-vdso.so.1 => (0x00007fff47ba5000)
libpython3.5m.so.1.0 => not found
libpthread.so.0 => /lib64/libpthread.so.0 (0x00007fdfaa32e000)
libdl.so.2 => /lib64/libdl.so.2 (0x00007fdfaa12a000)
libutil.so.1 => /lib64/libutil.so.1 (0x00007fdfa9f27000)
libm.so.6 => /lib64/libm.so.6 (0x00007fdfa9c24000)
libc.so.6 => /lib64/libc.so.6 (0x00007fdfa9862000)
/lib64/ld-linux-x86-64.so.2 (0x000055e85eac5000)
Run Code Online (Sandbox Code Playgroud)
出于某种原因,Python构建过程不会添加-rpath到链接行,这将"将目录添加到运行时库搜索路径".
如果您明确设置了库路径,它将起作用:
$ LD_LIBRARY_PATH=/tmp/py3/lib/ /tmp/py3/bin/python3
Python 3.5.1 (default, Jun 10 2016, 14:54:59)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-4)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>
Run Code Online (Sandbox Code Playgroud)
所以现在问题是你想要:
LD_LIBRARY_PATH在您的系统上全局设置/etc/ld.so.conf(或/etc/ld.so.conf.d/*)chrpath更改嵌入式路径export LD_RUN_PATH={prefix}/lib在运行之前configure和make
(如果{prefix}是你通过什么--prefix.你用错了路.)