0

I'm trying to install lxml for Python 3.4 on Centos7.

I have a Salt state that looks like this:

lxml:
  pip.installed:
    - bin_env: /opt/rh/rh-python34/root/bin/pip3
    - env_vars:
        INCLUDE: /usr/include/libxml2

But that doesn't work. With or without the env_vars, I get this error:

src/lxml/includes/etree_defs.h:14:31: fatal error: libxml/xmlversion.h: No such file or directory

So what environment variable do I have to add to get the build to actually see my xmlversion.h? It definitely exists:

# salt 'myminion' file.readdir /usr/include/libxml2/libxml | grep version
    - xmlversion.h
Wayne Werner
  • 49,299
  • 29
  • 200
  • 290

2 Answers2

1

Forrest's solution solved my problem, but here's what I did:

I had both libxml2-devel and libxslt-devel installed.

In the build output there was this line:

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

The inmportant part of that line:

-I/opt/rh/rh-python34/root/usr/include

I needed to get /usr/include/libxml2/libxml visible on that path ^^

So I before my pip.installed state, I added this state:

/opt/rh/rh-python34/root/usr/include/libxml
  file.symlink:
    - target: /usr/include/libxml2/libxml

And then everything worked just fine

Wayne Werner
  • 49,299
  • 29
  • 200
  • 290
0

If you have the xml dev packages installed already, can you please try a symlink like sudo ln -s libxml2/libxml libxml as noted here: src/lxml/etree_defs.h:9:31: fatal error: libxml/xmlversion.h: No such file or directory

Community
  • 1
  • 1
Forrest
  • 1,370
  • 9
  • 20