使用 --enable-shared 安装 Python 3 时出现问题
Problems installing Python 3 with --enable-shared
问题
我正在尝试使用 --enable-shared 选项安装 Python 3。安装 "succeeds" 但结果 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
背景
OS是Debian(压榨),之前安装的是Python2.6,因为其他代码依赖,需要保留,还有Apache 2.2。最终我要做的是在 Apache 上将 Django 设置为 运行,这意味着我正在尝试安装 mod_wsgi(或 mod_wsgi-express),这需要共享库。我已经尝试在 Python 安装中使用 --enable-shared
安装 mod_wsgi without,并且得到了......好吧,同样的事情,但是这次来自 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
我也按照 other question 的解决方案中所述设置 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
我也用 Python 3.4 尝试过,结果相同。我没有用 Python 2 尝试过,因为我不希望以后的开发仅限于 Python 2.7(因此即使安装成功也不能满足我的要求)。我还假设尝试不会提供任何新的或有用的信息。
我在 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
如果您查看 python 的 linking,它没有提供库的完整路径:
$ 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)
出于某种原因,Python 构建过程没有将 -rpath
添加到 link 行,这将 "add a directory to the runtime library search path."
如果您明确设置库路径,它将起作用:
$ 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.
>>>
所以现在问题是你是否想要:
- 在您的系统上全局设置
LD_LIBRARY_PATH
- 编辑
/etc/ld.so.conf
(或/etc/ld.so.conf.d/*
)
- 使用
chrpath
更改嵌入路径
export LD_RUN_PATH={prefix}/lib
在你 运行 configure
和 make
之前
(其中{prefix}
是你传递给--prefix
的。你用错了路径。)
如 mod_wsgi 文档中所述,在安装 mod_wsgi 时设置 LD_RUN_PATH
。
问题
我正在尝试使用 --enable-shared 选项安装 Python 3。安装 "succeeds" 但结果 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
背景
OS是Debian(压榨),之前安装的是Python2.6,因为其他代码依赖,需要保留,还有Apache 2.2。最终我要做的是在 Apache 上将 Django 设置为 运行,这意味着我正在尝试安装 mod_wsgi(或 mod_wsgi-express),这需要共享库。我已经尝试在 Python 安装中使用 --enable-shared
安装 mod_wsgi without,并且得到了......好吧,同样的事情,但是这次来自 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
我也按照 other question 的解决方案中所述设置 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
我也用 Python 3.4 尝试过,结果相同。我没有用 Python 2 尝试过,因为我不希望以后的开发仅限于 Python 2.7(因此即使安装成功也不能满足我的要求)。我还假设尝试不会提供任何新的或有用的信息。
我在 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
如果您查看 python 的 linking,它没有提供库的完整路径:
$ 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)
出于某种原因,Python 构建过程没有将 -rpath
添加到 link 行,这将 "add a directory to the runtime library search path."
如果您明确设置库路径,它将起作用:
$ 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.
>>>
所以现在问题是你是否想要:
- 在您的系统上全局设置
LD_LIBRARY_PATH
- 编辑
/etc/ld.so.conf
(或/etc/ld.so.conf.d/*
) - 使用
chrpath
更改嵌入路径 export LD_RUN_PATH={prefix}/lib
在你 运行configure
和make
之前 (其中{prefix}
是你传递给--prefix
的。你用错了路径。)
如 mod_wsgi 文档中所述,在安装 mod_wsgi 时设置 LD_RUN_PATH
。