Installing lxml in virtualenv via pip install error: command 'x86_64-linux-gnu-gcc' failed

心不动则不痛 提交于 2019-12-07 13:30:31

问题


when I activate virtualenv and type 'pip install lxml' installation process crashes with message:

/usr/bin/ld: cannot find -lz

collect2: error: ld returned 1 exit status

error: command 'x86_64-linux-gnu-gcc' failed with exit status 1

回答1:


The error you have to pay attention to is the first "/usr/bin/ld: cannot find -lz": tnhat means you don't have zlib-dev installed. Depending on your linux distribution it could be named zlib-dev or zlib1g-dev in Ubuntu, I don't know in other distros.




回答2:


Installing those dependencies fixed it for me (Debian 7):

sudo apt-get install libxml2-dev libxslt1-dev

source: src/lxml/etree_defs.h:9:31: fatal error: libxml/xmlversion.h: No such file or directory




回答3:


From https://askubuntu.com/questions/627140/cannot-install-lxml-on-ubuntu-14

sudo apt-get install -y libxml2-dev libxslt1-dev zlib1g-dev python3-pip



回答4:


For RHEL7/Fedora/CentOS in order to install lxml you need to:

YUM/DNF install libxml2 libxslt

...and possibly:

YUM/DNF install libxslt-devel libxml2-devel

Cheers!



来源:https://stackoverflow.com/questions/22239816/installing-lxml-in-virtualenv-via-pip-install-error-command-x86-64-linux-gnu-g

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