在Ubuntu 14.04上lxml安装失败

时间:2015-04-03 19:48:28

标签: ubuntu python-3.x pip lxml

我正在尝试安装lxml python模块:

sudo pip3 install lxml

以前我用过:

sudo apt-get install libxml2-dev libxslt1-dev python-dev

我得到这个输出(在失败前挂起几分钟) - 结束:

i686-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -g -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2 -fPIC -I/usr/include/libxml2 -I/tmp/pip_build_root/lxml/src/lxml/includes -I/usr/include/python3.4m -c src/lxml/lxml.etree.c -o build/temp.linux-i686-3.4/src/lxml/lxml.etree.o -w

i686-linux-gnu-gcc -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,-Bsymbolic-functions -Wl,-z,relro -g -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2 build/temp.linux-i686-3.4/src/lxml/lxml.etree.o -lxslt -lexslt -lxml2 -lz -lm -o build/lib.linux-i686-3.4/lxml/etree.cpython-34m.so

/usr/bin/ld: cannot find -lz

collect2: error: ld returned 1 exit status

/usr/lib/python3.4/distutils/dist.py:260: UserWarning: Unknown distribution option: 'bugtrack_url'

  warnings.warn(msg)

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

----------------------------------------
Cleaning up...
Command /usr/bin/python3 -c "import setuptools, tokenize;__file__='/tmp/pip_build_root/lxml/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-67svy8ob-record/install-record.txt --single-version-externally-managed --compile failed with error code 1 in /tmp/pip_build_root/lxml
Storing debug log for failure in /root/.pip/pip.log

在我的本地计算机上成功安装,在VPS上失败。

2 个答案:

答案 0 :(得分:0)

转到http://www.lfd.uci.edu/~gohlke/pythonlibs/。它保证了一切安装。只需转到LXML部分,为您的机器和Python类型选择合适的whl文件(它们有32位和64位,Python 2.6到最新,甚至是beta 3.5!)。 Pip安装方向盘,你已经完成了。

答案 1 :(得分:0)

This answer为我工作:

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