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.
Debian 7.4 - LXML compilation failed with Python 3.4.0
-
29-06-2023 - |
Вопрос
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.
Решение
Другие советы
You're right Photoionized,
while installing another package (setuptools) it claims for the zlib python module that must be set at compile time. Don't now why but I thought it was a similar problem as the unknown -lz option that sounds like Library Zlib ?
So I installed the zlib1g librairy and its sources , compile again the python-3.4.0 with the --with-zlib option.
./compile --prefix=opt/python-3.4.0 --with-zlib
make
sudo make install
then create a new link to the command
sudo rm /usr/bin/python3 && ln -s /usr/bin/python3 /opt/python-3.4.0/bin/python3.4m
After that the installation ended succesfully in the lxml source directory
sudo python3 setup.py install
Thanks again for your answer