Question

I am using openpyxl python package in my application. I am getting the following message when using the same.

/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 above, and the version in my machine is 3.2.0. When I try to upgrade lxml to the latest version ie 3.3.5, it is getting interrupted with 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 in resolving the issue.

PS:- I have already installed lxml dependent packages python-dev, libxml2-dev and libxslt1-dev in my machine.

Was it helpful?

Solution 3

I think what you're missing is zlib1g-dev.

sudo apt-get install zlib1g-dev

Running above command will solve the issue.

OTHER TIPS

sudo pip install --upgrade lxml

On Ubuntu (and other Debian derivatives), before you build some piece of software, ensure that its build dependencies are installed. Using your example, run this:

sudo apt-get build-dep python-lxml

That is likely going to require a whole bunch of packages, one of which is zlib1g-dev, as mentioned.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top