我已经通过了几个关于Python的StackOverflow问题;bzip2。这些对我现在的状态很有帮助。以下是我到目前为止所做的以及我遇到的问题:
- 我做不是有根访问权限,不能安装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
告诉Python在源代码配置过程中安装的bzip 1.0.6库在哪里,以便它检测bzip2 devel头文件并正确安装模块的正确方法是什么?
好吧,我花了几个月的时间才弄明白这个问题,但我终于回来了,并设法解决了这个问题。
-
安装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...
-
Install Python from source:
# 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在技术上不是问题的一部分,但它是驱使我完成上述所有内容的原因,所以我不妨包括最后几个命令,使用源代码安装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