/ usr / bin / ld:找不到-lz

我正在尝试在virtualenv中运行ubuntu / trusty64的虚拟机上安装lxml但是我在下面收到此错误并且无法理解它。

/usr/bin/ld: cannot find -lz 

第一次出现这个错误,我看着安装lz。 我使用sudo apt-get install mtools安装它包含lz然而错误仍然发生因此我认为这可能是一个符号链接问题可能一个文件应该链接到lz但不知道什么文件。 lz有一个符号链接到uz,但我不知道有什么影响,也不想改变它,因为它打破了别的东西。 有什么想法指出我正确的方向?

 building 'lxml.etree' extension creating build/temp.linux-x86_64-2.7 creating build/temp.linux-x86_64-2.7/src creating build/temp.linux-x86_64-2.7/src/lxml x86_64-linux-gnu-gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/usr/include/libxml2 -Isrc/lxml/includes -I/usr/include/python2.7 -c src/lxml/lxml.etree.c -o build/temp.linux-x86_64-2.7/src/lxml/lxml.etree.o -w x86_64-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-x86_64-2.7/src/lxml/lxml.etree.o -lxslt -lexslt -lxml2 -lz -lm -o build/lib.linux-x86_64-2.7/lxml/etree.so /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 ---------------------------------------- Cleaning up... Command /home/vagrant/.virtualenvs/devenv/bin/python -c "import setuptools, tokenize;__file__='/home/vagrant/.virtualenvs/devenv/build/lxml/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-yUqdLy-record/install-record.txt --single-version-externally-managed --compile --install-headers /home/vagrant/.virtualenvs/devenv/include/site/python2.7 failed with error code 1 in /home/vagrant/.virtualenvs/devenv/build/lxml Storing debug log for failure in /home/vagrant/.pip/pip.log (devenv)vagrant@vagrant-ubuntu-trusty-64:/vagrant/woowoo/woowoo_webapp$ ls -l /usr/bin/ld lrwxrwxrwx 1 root root 6 Sep 16 16:11 /usr/bin/ld -> ld.bfd (devenv)$ vim /usr/bin/ld.bfd (devenv)$ ls -l /usr/bin/ld.bfd -rwxr-xr-x 1 root root 1050912 Sep 16 16:10 /usr/bin/ld.bfd (devenv)$ ls -l /usr/bin/ld lrwxrwxrwx 1 root root 6 Sep 16 16:11 /usr/bin/ld -> ld.bfd (devenv)$ ls -l /usr/bin/lzlrwxrwxrwx 1 root root 2 Oct 10 2013 /usr/bin/lz -> uz (devenv)$ ls -l /usr/bin/uz -rwxr-xr-x 1 root root 2496 Oct 10 2013 /usr/bin/uz 

您需要安装lxml的构建依赖项才能编译它。 如果您在apt源中启用了源包数据,请尝试执行sudo apt-get build-dep python-lxml

缺少的不是lz命令,而是zlib库的开发文件。 您需要安装zlib1g-dev才能获得此function。