libxml2/libxslt에 대한 사용자 정의 설치 위치로 lxml을 설치하는 데 문제가 있습니다.

libxml2/libxslt에 대한 사용자 정의 설치 위치로 lxml을 설치하는 데 문제가 있습니다.

lxmlRHEL을 실행하는 슈퍼컴퓨터에 내 계정으로 호출되는 Python 모듈을 설치하려고 합니다 .

그래요아니다루트 액세스 또는 슈퍼유저 상태가 있어야 합니다.

lxml빌드해야 하는 헤더 파일이 포함되어 있으므로 libxml2및 의 dev/devel 버전이 필요합니다 . 하지만 슈퍼컴퓨터에는 루트 디렉터리에 개발 버전이 아닌 버전이 설치되어 있으므로 소스에서 빌드하여 개발 버전을 내 디렉터리에 설치했습니다 .libxsltlxml/usrhome

둘 다 오류 없이 원활하게 빌드되었으며 필요한 헤더 파일은 모두 $HOME/usr/local/include/libxml2/libxml등에 있습니다.

그러나 시도할 때마다 루트에서 pip install lxml비개발자 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.

모든 기반을 확실하게 다루기 위해 소스 타르볼에 포함된 문서 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

그래서 기본적으로 내 etc. 디렉토리 /user/local/lib대신 보는 것과 동일한 문제가 발생합니다 .$HOME/user

이 문제를 어떻게 해결하나요?

답변1

bin두 패키지(libxml2/libxslt)의 하위 디렉터리 가 PATH. 여기 *-config에는 libxml2/libxslt가 설치된 위치를 찾기 위해 lxml을 컴파일하는 동안 사용되는 스크립트가 포함되어 있습니다 .

[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

관련 정보