lxml
我正在尝试在运行 RHEL 的超级计算机上安装调用我的帐户的 python 模块。
我愿意不是具有 root 访问权限或超级用户身份。
lxml
libxml2
需要和的 dev/devel 版本,因为它们包含需要构建的libxslt
头文件。lxml
但是超级计算机已将非开发版本安装到其根目录中,因此我通过从源代码构建它们/usr
将开发版本安装到我的目录中。home
两者都构建顺利,没有抛出任何错误,并且所有必需的头文件都在$HOME/usr/local/include/libxml2/libxml
等中。
但是,每当我尝试时,它都会尝试在根目录中pip install lxml
使用非 dev libxml2
& :libxslt
/bin
[myusername@q0144 ~]$ pip install --install-option="--prefix=$HOME/python_modules" lxml
... (some unimportant messages) ...
Building against libxml2/libxslt in the following directory: /usr/local/lib
building 'lxml.etree' extension
gcc -pthread -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/usr/local/include -I/usr/local/include/libxml2 -I/tmp/pip_build_myusername/lxml/src/lxml/includes -I/N/soft/rhel6/python/2.7.3/include/python2.7 -c src/lxml/lxml.etree.c -o build/temp.linux-x86_64-2.7/src/lxml/lxml.etree.o -w
In file included from src/lxml/lxml.etree.c:346:
/tmp/pip_build_myusername/lxml/src/lxml/includes/etree_defs.h:9:31: error: libxml/xmlversion.h: No such file or directory
/tmp/pip_build_myusername/lxml/src/lxml/includes/etree_defs.h:11:4: error: #error the development package of libxml2 (header files etc.) is not installed correctly
...(many more lines saying that the headers are missing, etc.)
还有几十行表明开发包未正确安装,因为它正在查找错误的包。
如何让系统使用我安装的libxml2
/版本?libxslt
我什至$HOME/bin
首先$HOME/usr
在.cshrc
.
为了确保涵盖所有基础,我还尝试按照源 tarball 中包含的文档lxml
中的说明从源代码构建:build.txt
[myusername@q0144 lxml-3.3.5]$ python setup.py build_ext -i -I $HOME/usr/include/libxml2/libxml --without-cython --with-xslt-config=$HOME/usr/local/bin/xslt-config
Building lxml version 3.3.5.
Building without Cython.
Using build configuration of libxslt 1.1.28
Building against libxml2/libxslt in the following directory: /usr/local/lib
/N/soft/rhel6/python/2.7.3/lib/python2.7/distutils/dist.py:267: UserWarning: Unknown distribution option: 'bugtrack_url'
warnings.warn(msg)
running build_ext
building 'lxml.etree' extension
gcc -pthread -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/usr/local/include -I/usr/include/libxml2 -I/N/hd00/myusername/Quarry/python_modules/lxml-3.3.5/src/lxml/includes -I/N/u/myusername/Quarry/usr/include/libxml2/libxml -I/N/soft/rhel6/python/2.7.3/include/python2.7 -c src/lxml/lxml.etree.c -o build/temp.linux-x86_64-2.7/src/lxml/lxml.etree.o -w
In file included from src/lxml/lxml.etree.c:346:0:
/N/hd00/rccaton/Quarry/python_modules/lxml-3.3.5/src/lxml/includes/etree_defs.h:
13:32: fatal error: libxslt/xsltconfig.h: No such file or directory
compilation terminated.
error: command 'gcc' failed with exit status 1
所以我基本上遇到了同样的问题,/user/local/lib
而不是我的$HOME/user
等目录。
我该如何解决这个问题?
答案1
确保bin
两个包 (libxml2/libxslt) 的子目录都位于您的PATH
.它们包含*-config
在编译 lxml 期间使用的脚本来查找 libxml2/libxslt 的安装位置。
[pdobrogost@host /]$ echo $PATH
(...):/opt/libxslt-1.1.27/bin:/opt/libxml2-2.6.32/bin:(...)
[pdobrogost@host /]$ which xml2-config && which xslt-config
/opt/libxml2-2.6.32/bin/xml2-config
/opt/libxslt-1.1.27/bin/xslt-config