2015-04-03 131 views
0

我试图安装lxml Python模块:LXML安装失败在Ubuntu 14.04

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上失败。

+0

'易于得到安装python3-lxml'是解决方案,安装了罚款。但我仍然不明白为什么从源代码安装失败。 – Croll 2015-04-03 19:57:05

+0

错误消息表明您缺少zlib。 – tripleee 2015-04-03 19:59:14

回答

0

This answer工作对我来说:

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

您使用的是哪个版本的ubuntu? – Croll 2016-02-04 11:46:55

+0

Ubuntu版本:14.04.3 – 2016-02-04 11:51:06

0

转到http://www.lfd.uci.edu/~gohlke/pythonlibs/。这是一切安全的保证。只需进入LXML部分,然后为您的机器和Python类型选择正确的whl文件(它们具有32位和64位,Python 2.6到最新,甚至是beta 3.5!)。点安装轮子,你就完成了。

+0

问题是这些二进制文件是针对Windows平台的,而问题针对的是Ubuntu – 2016-01-04 17:13:12