【问题标题】:Repeatedly failing to install scrapy and lxml多次安装scrapy和lxml失败
【发布时间】:2014-05-08 19:08:16
【问题描述】:

我以前使用 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

对于 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。我尝试过的其他模块安装良好(虽然我只安装了少数)。

【问题讨论】:

  • 对于scrapy,调试日志中是否有额外的信息?你有安装 OpenSSL 吗?
  • @jdigital 废话,感谢 openssl 提示!我安装了它,但没有安装开发库。把它改成那个就行了。唷。
  • 嘿@user3115915 你能链接到开发库吗?遇到同样的问题,无法解决...

标签: python ubuntu scrapy lxml


【解决方案1】:

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

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

【讨论】:

    【解决方案2】:

    就我而言,我解决了安装 Manuel 提到的所有库以及额外库的问题:libffi-dev

    https://askubuntu.com/questions/499714/error-installing-scrapy-in-virtualenv-using-pip

    【讨论】:

      【解决方案3】:

      更新自 @Mario C. 和 @Manuel,

      这里是命令:

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

      【讨论】:

      • 我的系统上缺少的其他东西:python-dev(或在我的情况下为python3.4-dev,因为为 python2.7 安装了 python-dev)
      猜你喜欢
      • 2014-07-31
      • 2016-12-13
      • 2015-10-28
      • 2013-07-25
      • 2015-06-08
      • 2014-06-27
      • 2014-06-12
      • 2015-07-18
      • 2012-06-11
      相关资源
      最近更新 更多