我已经回答了几个关于 Python 和 bzip2 的 StackOverflow 问题。这些对让我达到我现在所处的状态非常有帮助。这是我到目前为止所做的以及我遇到的问题:
- 我没有有root权限,无法安装libbz2-dev(el)
- /usr/bin/bzip2 是 1.0.3 版本
- /usr/bin/python 是 2.4.3 版本
- GNU Stow正被用于管理类似于自制软件工作方式的库
我需要 Python 2.7.3 与 bzip2 模块一起安装,以便从源代码正确编译 node.js。是的,我很抱歉,但我确实必须以普通用户的身份从源代码中完成所有这些操作。
我已经从源代码安装了 bzip2,如下所示:
$ make -f Makefile-libbz2_so
$ make
$ make install PREFIX=${STOW}/bzip2-1.0.6
$ cp libbz2.so.1.0.6 ${STOW}/bzip2-1.0.6/lib/
$ cd ${STOW}/bzip2-1.0.6/lib
$ ln -s libbz2.so.1.0.6 libbz2.so.1.0
$ cd ${STOW}
$ stow bzip2-1.0.6
我的 PATH 中有 stow 的根目录,所以这导致:
$ bzip2 -V
# [...] Version 1.0.6
这表明我的 PATH 中使用了正确的 bzip2。
接下来我继续从源代码编译 Python 并运行以下命令:
$ cd Python-2.7.3
$ ./configure --prefix=${STOW}/Python-2.7.3
$ make
# Complains about several missing modules, of which "bz2" is the one I care about
$ make install prefix=${STOW}/Python-2.7.3 # unimportant as bz2 module failed to install
在安装 bzip 1.0.6 库的源代码所在的源代码配置期间告诉 Python 的正确方法是什么,以便它检测 bzip2 开发 header 并正确安装模块?
最佳答案
好吧,我花了几个月的时间才解决这个问题,但我终于回来并设法解决了这个问题。
从源代码安装 bzip2:
# Upload bzip2-1.0.6.tar.gz to ${SRC} $ cd ${SRC} $ tar -xzvf bzip2-1.0.6.tar.gz $ cd bzip2-1.0.6 $ export CFLAGS="-fPIC" $ make -f Makefile-libbz2_so $ make $ make install PREFIX=${STOW}/bzip2-1.0.6 $ cp libbz2.so.1.0.6 ${STOW}/bzip2-1.0.6/lib/ $ cd ${STOW}/bzip2-1.0.6/lib $ ln -s libbz2.so.1.0.6 libbz2.so.1.0 $ cd ${STOW} $ stow bzip2-1.0.6 $ source ${HOME}/.bash_profile $ bzip2 --version #=> bzip2, a block-soring file compressor. Version 1.0.6...
从源代码安装 Python:
# Upload Python-2.7.3.tar.gz to ${SRC} $ cd ${SRC} $ tar -xzvf Python-2.7.3.tar.gz $ cd Python-2.7.3 $ export CLFAGS="-fPIC" $ export C_INCLUDE_PATH=${STOW}/../include $ export CPLUS_INCLUDE_PATH=${C_INCLUDE_PATH} $ export LIBRARY_PATH=${STOW}/../lib $ export LD_RUN_PATH=${LIBRARY_PATH} $ ./configure --enable-shared --prefix=${STOW}/Python-2.7.3 --libdir=${STOW}/../lib $ make $ make install prefix=${STOW}/Python-2.7.3 $ cd ${STOW} $ stow Python-2.7.3 $ source ${HOME}/.bash_profile $ python -V #=> Python 2.7.3 $ python -c "import bz2; print bz2.__doc__" #=> The python bz2 module provides...
虽然从技术上讲 node.js 不是问题的一部分,但它是驱使我完成上述所有内容的原因,所以我不妨包括最后几个命令,以使用源安装从源安装 node.js Python 2.7.3 和 bzip2 1.0.6:
从源代码安装 node.js:
# Upload node-v0.10.0.tar.gz to ${SRC} $ cd ${SRC} $ tar -xzvf node-v0.10.0.tar.gz $ cd node-v0.10.0 $ ./configure --prefix=${STOW}/node-v0.10.0 $ make $ make install prefix=${STOW}/node-v0.10.0 $ cd ${STOW} $ stow node-v0.10.0 $ source ${HOME}/.bash_profile $ node -v #=> v0.10.0
关于python - 如何为 Python 安装手动传递 bzip2 安装源?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15910219/