反复无法安装scrapy和lxml

phi*_*hil 12 python ubuntu lxml scrapy

我之前使用过Anaconda来处理python,但我开始使用虚拟环境.

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

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

对于scrapy:

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
Run Code Online (Sandbox Code Playgroud)

对于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
Run Code Online (Sandbox Code Playgroud)

我尝试按照scrapy的文档安装它,但是当我调用python的已安装模块时,scrapy仍未列出.

有任何想法吗?谢谢 - 真的很感激!

如果重要的话,我正在使用Ubuntu 13.10.我试过的其他模块安装得很好(虽然我只去了少数).

Man*_*uel 44

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

sudo apt-get install libxslt1-dev libxslt1.1 libxml2-dev libxml2 libssl-dev
sudo pip install scrapy
Run Code Online (Sandbox Code Playgroud)