安装scrapy时出错

时间:2016-07-12 07:55:25

标签: python ubuntu openssl

我正在尝试使用命令sudo pip install scrapy安装scrapy,但是我收到的错误消息如下:

build/temp.linux-x86_64-2.7/_openssl.c:429:30: fatal error: openssl/opensslv.h: No such file or directory
    compilation terminated.
    error: command 'x86_64-linux-gnu-gcc' failed with exit status 1

    ----------------------------------------
Command "/usr/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-tVcVY7/cryptography/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-zyty58-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-build-tVcVY7/cryptography/

该错误似乎与OpenSSL有关,需要根据http://doc.scrapy.org/en/latest/intro/install.html进行安装。但是,如果我运行sudo apt-get install openssl,我会收到一条消息,表明它已经安装:

Reading package lists... Done
Building dependency tree       
Reading state information... Done
openssl is already the newest version (1.0.2g-1ubuntu4.1).
The following packages were automatically installed and are no longer required:
  linux-headers-4.4.0-21 linux-headers-4.4.0-21-generic linux-headers-4.4.0-22
  linux-headers-4.4.0-22-generic linux-image-4.4.0-21-generic
  linux-image-4.4.0-22-generic linux-image-extra-4.4.0-21-generic
  linux-image-extra-4.4.0-22-generic
Use 'sudo apt autoremove' to remove them.
0 upgraded, 0 newly installed, 0 to remove and 135 not upgraded.

如何解决此问题以安装scrapy?

3 个答案:

答案 0 :(得分:4)

使用Ubuntu软件包管理器apt-get安装scrapy。 apt-get将自动处理依赖项

sudo apt-get install python-scrapy

答案 1 :(得分:3)

正如install documentation中所述,您应该执行以下操作:

sudo apt-get install python-dev python-pip libxml2-dev libxslt1-dev zlib1g-dev libffi-dev libssl-dev

答案 2 :(得分:3)

问题是我必须通过命令sudo apt-get install libssl-dev安装OpenSSL开发包。