python - 反复安装 scrapy 和 lxml 失败

标签 python ubuntu scrapy lxml

我以前使用 Anaconda 来处理 python,但我现在开始使用虚拟环境。

我设置了 virtualenv 和 virtualenvwrapper,并一直在尝试为我想尝试的项目添加模块,特别是 scrapy 和 lxml。

每次我 pip 安装时,我都会遇到错误。

对于抓取:

File "/home/philip/Envs/venv/local/lib/python2.7/site-packages/setuptools/command/easy_install.py", line 1003, in run_setup
    raise DistutilsError("Setup script exited with %s" % (v.args[0],))

distutils.errors.DistutilsError: Setup script exited with error: command 'x86_64-linux-gnu-gcc' failed with exit status 1

---------------------------------------
Cleaning up...
Command python setup.py egg_info failed with error code 1 in /home/philip/Envs/venv/build/cryptography
Storing debug log for failure in /home/philip/.pip/pip.log

对于 lxml:

In file included from src/lxml/lxml.etree.c:346:0:

/home/philip/Envs/venv/build/lxml/src/lxml/includes/etree_defs.h:9:31: fatal error: libxml/xmlversion.h: No such file or directory

 include "libxml/xmlversion.h"

                               ^

compilation terminated.

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

----------------------------------------
Cleaning up... Command /home/philip/Envs/venv/bin/python -c "import setuptools, tokenize;__file__='/home/philip/Envs/venv/build/lxml/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-zIsPdl-record/install-record.txt
--single-version-externally-managed --compile --install-headers /home/philip/Envs/venv/include/site/python2.7 failed with error code 1 in /home/philip/Envs/venv/build/lxml Storing debug log for failure in /home/philip/.pip/pip.log

我尝试按照 scrapy's documentation 安装它, 但是当我调用 python 的已安装模块时,仍然没有列出 scrapy。

有什么想法吗?谢谢——真的很感激!

如果重要的话,我正在使用 Ubuntu 13.10。我尝试过的其他模块安装正常(尽管我只安装了少数)。

最佳答案

我在 Ubuntu 14.04 中遇到了同样的问题。我已经使用@jdigital 链接的页面说明和@user3115915 指向的 openssl-dev 库解决了它。只是为了帮助别人:

sudo apt-get install libxslt1-dev libxslt1.1 libxml2-dev libxml2 libssl-dev
sudo pip install scrapy

关于python - 反复安装 scrapy 和 lxml 失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22727782/

相关文章:

python - Scrapy:如何设置 HTTP 代理以连接到 HTTPS 网站(HTTP 有效)?

python - Scrapy不处理Xpath和CSS选择器中的TBODY

python - 为什么这段代码中的第二个列表打印了三次?

python - 基于多个条件的 Pandas 数据框条件列仅适用于第一个条件?

docker - apt -o APT::Keep-Downloaded-Packages=true install <pkg> 不会将 debs 保留在 docker 中

python - simpleeval 安装问题 :use _2to3 invalid

python - 如何从堆栈交换站点获取数据

python - 如何将 pandas 列与多索引数据帧的一部分相乘

python - 用户的管理员(仅限)注册,Flask-Security

python - 尝试使用网络摄像头python opencv捕获视频时出现gstreamer严重错误