【发布时间】:2014-12-09 22:04:39
【问题描述】:
我尝试使用 sudo pip install lxml 和 sudo pip install --upgrade lxml 在 virtualenv 中安装 lxml,但在这两种情况下都得到以下结果:
x86_64-linux-gnu-gcc -pthread -shared -Wl,-O1 -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 /usr/bin/python -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-nmFOYf-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
我已经尝试了所有发布的解决方案here,这意味着我安装了libxml2-dev、libxslt-dev 和python-dev,我还安装了build-essential
我目前正在运行基于 Linux Mint 17 Debian,它使用 apt-get 作为包管理器。python-lxml 已经预安装。
【问题讨论】:
-
你为什么在 virtualenv 中使用
sudo?您是否以root身份创建了virtualenv?如果是这样,为什么?或者您是否尝试将其安装到系统站点包中,即使您在 virtualenv 中?如果是这样,为什么不从 virtualenv 之外进行呢? -
@abarnert 好吧,我第一次没有sudo,然后我尝试全局安装lxml,但没有成功。
-
只是随机混合使用和不使用 sudo 的 virtualenv 和全局安装只会导致破坏的 virtualenv 与搞砸的权限。不要那样做。
-
仅供参考,您无需编辑标题即可说“已解决”。只需标记一个接受的答案(您已经完成)就足够了。
-
另外,将来,对于与安装相关的问题,请在您的问题中提供有关您平台的信息,最好是作为标签。如果你一开始就有 Linux Mint 标签,我可以直接告诉你
sudo apt-get install zlib1g-dev,而不是试图抽象地解释你需要使用你的平台的安装程序来安装你的平台的 zlib 开发包。跨度>
标签: python python-2.7 lxml linux-mint