【问题标题】:How do I add an include path when pip installing lxml on Centos7 using Salt?使用 Salt 在 Centos7 上 pip 安装 lxml 时如何添加包含路径?
【发布时间】:2016-04-09 18:49:30
【问题描述】:

我正在尝试在 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:致命错误:libxml/xmlversion.h:没有这样的文件或目录

那么我必须添加什么环境变量才能让构建真正看到我的xmlversion.h?它肯定存在:

# salt 'myminion' file.readdir /usr/include/libxml2/libxml | grep version
    - xmlversion.h

【问题讨论】:

    标签: python build pip lxml salt-stack


    【解决方案1】:

    Forrest 的解决方案解决了我的问题,但这是我所做的:

    我同时安装了libxml2-devellibxslt-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
    

    然后一切正常

    【讨论】:

      【解决方案2】:

      如果您已经安装了 xml 开发包,请尝试使用 sudo ln -s libxml2/libxml libxml 之类的符号链接,如下所示:src/lxml/etree_defs.h:9:31: fatal error: libxml/xmlversion.h: No such file or directory

      【讨论】:

      • 效果很好。有趣的是 - libxslt 不需要符号链接,一旦我有一个用于 libxml 的符号链接。
      猜你喜欢
      • 2017-05-21
      • 2016-04-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-10-23
      • 2017-05-29
      • 1970-01-01
      相关资源
      最近更新 更多