Failed to install lxml verison 3.3.5 in ubuntu

I am using the openpyxl python package in my application. When using this, I get the following message.

/usr/local/lib/python2.7/dist-packages/openpyxl/ INIT .py: 31: UserWarning: The installed version of lxml is too old to be used with openpyxl

warnings.warn ("The installed version of lxml is too old to be used with openpyxl")

Openpyxl requires lxml version 3.2.5 or higher, and the version on my computer is 3.2.0. When I try to update lxml to the latest version, i.e. 3.3.5, it is interrupted by the following message.

i686-linux-gnu-gcc -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-Bsymbolic-functions -Wl,-z,relro -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -D_FORTIFY_SOURCE=2 -g -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security build/temp.linux-i686-2.7/src/lxml/lxml.etree.o -lxslt -lexslt -lxml2 -lz -lm -o build/lib.linux-i686-2.7/lxml/etree.so /usr/bin/ld: cannot find -lz collect2: error: ld returned 1 exit status error: command 'i686-linux-gnu-gcc' failed with exit status 1 ---------------------------------------- Rolling back uninstall of lxml Replacing /usr/lib/python2.7/dist-packages/lxml Replacing /usr/lib/python2.7/dist-packages/lxml-3.2.0.egg-info Cleaning up... Removing temporary dir /tmp/pip_build_root... Command /usr/bin/python -c "import setuptools;__file__='/tmp/pip_build_root/lxml/setup.py';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-ov0PUy-record/install-record.txt --single-version-externally-managed failed with error code 1 in /tmp/pip_build_root/lxml 

I need help solving a problem.

PS: - I already installed the lxml-dependent packages python-dev, libxml2-dev and libxslt1-dev on my computer.

0
python lxml openpyxl
source share
3 answers

I think you are missing zlib1g-dev.

 sudo apt-get install zlib1g-dev 

Executing the above command will solve the problem.

+2
source share
 sudo pip install --upgrade lxml 
+4
source share

On Ubuntu (and other Debian derivatives), make sure that its build dependencies are installed before creating any software. Using your example, run this:

 sudo apt-get build-dep python-lxml 

Most likely, you will need a whole bunch of packages, one of which is zlib1g-dev , as indicated .

+3
source share

All Articles