使用Salt在Centos7上pip安装lxml时如何添加包含路径?
How do I add an include path when pip installing lxml on Centos7 using Salt?
我正在尝试在 Centos7 上为 Python 3.4 安装 lxml。
我的 Salt 状态如下所示:
lxml:
pip.installed:
- bin_env: /opt/rh/rh-python34/root/bin/pip3
- env_vars:
INCLUDE: /usr/include/libxml2
但这不起作用。有或没有 env_vars,我都会收到此错误:
src/lxml/includes/etree_defs.h:14:31: fatal error: libxml/xmlversion.h: No such file or directory
那么我必须添加什么环境变量才能让构建真正看到我的 xmlversion.h
?它确实存在:
# salt 'myminion' file.readdir /usr/include/libxml2/libxml | grep version
- xmlversion.h
如果您已经安装了 xml 开发包,请尝试像 sudo ln -s libxml2/libxml libxml
这样的符号链接,如下所述:src/lxml/etree_defs.h:9:31: fatal error: libxml/xmlversion.h: No such file or directory
Forrest 的解决方案解决了我的问题,但我是这样做的:
我同时安装了 libxml2-devel
和 libxslt-devel
。
在构建输出中有这一行:
gcc -pthread -Wno-unused-result -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -I/opt/rh/rh-python34/root/usr/include -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -fPIC -Isrc/lxml/includes -I/opt/rh/rh-python34/root/usr/include/python3.4m -c src/lxml/lxml.etree.c -o build/temp.linux-x86_64-3.4/src/lxml/lxml.etree.o -w
该行的重要部分:
-I/opt/rh/rh-python34/root/usr/include
我需要让 /usr/include/libxml2/libxml
在那条路径上可见 ^^
所以我在 pip.installed 状态之前,添加了这个状态:
/opt/rh/rh-python34/root/usr/include/libxml
file.symlink:
- target: /usr/include/libxml2/libxml
然后一切正常
我正在尝试在 Centos7 上为 Python 3.4 安装 lxml。
我的 Salt 状态如下所示:
lxml:
pip.installed:
- bin_env: /opt/rh/rh-python34/root/bin/pip3
- env_vars:
INCLUDE: /usr/include/libxml2
但这不起作用。有或没有 env_vars,我都会收到此错误:
src/lxml/includes/etree_defs.h:14:31: fatal error: libxml/xmlversion.h: No such file or directory
那么我必须添加什么环境变量才能让构建真正看到我的 xmlversion.h
?它确实存在:
# salt 'myminion' file.readdir /usr/include/libxml2/libxml | grep version
- xmlversion.h
如果您已经安装了 xml 开发包,请尝试像 sudo ln -s libxml2/libxml libxml
这样的符号链接,如下所述:src/lxml/etree_defs.h:9:31: fatal error: libxml/xmlversion.h: No such file or directory
Forrest 的解决方案解决了我的问题,但我是这样做的:
我同时安装了 libxml2-devel
和 libxslt-devel
。
在构建输出中有这一行:
gcc -pthread -Wno-unused-result -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -I/opt/rh/rh-python34/root/usr/include -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -fPIC -Isrc/lxml/includes -I/opt/rh/rh-python34/root/usr/include/python3.4m -c src/lxml/lxml.etree.c -o build/temp.linux-x86_64-3.4/src/lxml/lxml.etree.o -w
该行的重要部分:
-I/opt/rh/rh-python34/root/usr/include
我需要让 /usr/include/libxml2/libxml
在那条路径上可见 ^^
所以我在 pip.installed 状态之前,添加了这个状态:
/opt/rh/rh-python34/root/usr/include/libxml
file.symlink:
- target: /usr/include/libxml2/libxml
然后一切正常