我之前使用过Anaconda来处理python,但是我开始使用虚拟环境。
我设置了virtualenv和virtualenvwrapper,并且一直在尝试为我想尝试的项目添加模块,特别是scrapy和lxml。
每次点击安装时,我都会遇到错误。
对于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
对于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。我试过的其他模块安装得很好(虽然我只是为了少数人而去)。
答案 0 :(得分: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
答案 1 :(得分:1)
就我而言,我解决了安装Manuel所提及的所有库以及额外库的问题:libffi-dev
https://askubuntu.com/questions/499714/error-installing-scrapy-in-virtualenv-using-pip
答案 2 :(得分:0)
更新自@Mario C.和@Manuel,
这是命令:
sudo apt-get install libxslt1-dev libxslt1.1 libxml2-dev libxml2 libssl-dev libffi-dev
sudo pip install scrapy