Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Debian 7.4 - LXML compilation failed with Python 3.4.0

I've just installed Debian 7.4 on my PC. I need python 3.3.2 or higher AND python3-lxml for my inner developments. As python 3.2 is the base line for the python3.x series in debian wheezy Ive' compiled a 3.4.0 python version and uninstalled the old 3.2. (note that the process also un-installed some gnome dependencies).

After that work Python3 packages (cherrypy for example) install fine and modules can be successfully imported inside the interpreter.

When trying to install python3-lxml , the system needs to install the lxml repository dependencies python3.2 ... that I just don't want to.

So I decided to compile lxml over python 3.4.0.

Dependencies installed : * libxml2 >= 2.7.8 * libxml2-dev * libxslt1= >= 1.1.26 * libxslt1-dev

sudo apt-get install  libxml2 libxml2-dev libxslt1 libxslt1-dev

I think that only the *-dev packages are required, aren't they ?

The problem is that I faced this issue while compiling in the source directory :

jeby6372@mercure:~/Pack/lxml-3.3.4$ sudo python3 setup.py build
Building lxml version 3.3.4.
Building without Cython.
Using build configuration of libxslt 1.1.26
Building against libxml2/libxslt in the following directory: /usr/lib
/opt/python-3.4.0/lib/python3.4/distutils/dist.py:260: UserWarning: Unknown distribution option: 'bugtrack_url'
  warnings.warn(msg)
running build
running build_py
copying src/lxml/includes/lxml-version.h -> build/lib.linux-x86_64-3.4/lxml/includes
running build_ext
building 'lxml.etree' extension
gcc -pthread -Wno-unused-result -Werror=declaration-after-statement -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/usr/include/libxml2 -I/home/jeby6372/Pack/lxml-3.3.4/src/lxml/includes -I/opt/python-3.4.0/include/python3.4m -c src/lxml/lxml.etree.c -o build/temp.linux-x86_64-3.4/src/lxml/lxml.etree.o -w
gcc -pthread -shared build/temp.linux-x86_64-3.4/src/lxml/lxml.etree.o -L/usr/lib -lxslt -lexslt -lxml2 -lz -lm -o build/lib.linux-x86_64-3.4/lxml/etree.cpython-34m.so
/usr/bin/ld: cannot find -lz
collect2: error: ld returned 1 exit status
error: command 'gcc' failed with exit status 1

the -lz option is not recognized by the gcc. For information i've install the tool chain with :

sudo apt-get install build-essential

Any idea ?

In advance thanks for your help.

like image 924
Emmanuel BRUNET Avatar asked Jun 10 '26 17:06

Emmanuel BRUNET


1 Answers

The linker can't find libz when trying to compile the python c-extension. I believe you need the zlib dev package on Debian. Try apt-get install zlib1g-dev and then try and rebuild.

like image 63
photoionized Avatar answered Jun 12 '26 11:06

photoionized



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!