Not able to install lxml verison 3.3.5 in ubuntu

自古美人都是妖i 提交于 2020-01-06 02:20:08

问题


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.


回答1:


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

sudo apt-get install zlib1g-dev

Running above command will solve the issue.




回答2:


sudo pip install --upgrade lxml



回答3:


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.



来源:https://stackoverflow.com/questions/23570913/not-able-to-install-lxml-verison-3-3-5-in-ubuntu

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!