
lxml
RHEL を実行しているスーパーコンピューターに自分のアカウントと呼ばれる Python モジュールをインストールしようとしています。
私はしますないルートアクセス権またはスーパーユーザーステータスを持っていること。
lxml
libxml2
およびの dev/devel バージョンが必要ですlibxslt
。これらにはビルドに必要なヘッダー ファイルが含まれているためですlxml
。ただし、スーパーコンピューターのルート ディレクトリには非 dev バージョンがインストールされているため、ソースからビルドして/usr
dev バージョンを自分のディレクトリにインストールしました。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
つまり、基本的には、etc. ディレクトリの代わりに参照する場合と同じ問題が発生します$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