安装scrapy出错

3

我正在尝试使用命令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个回答

4
使用Ubuntu的软件包管理器apt-get安装scrapy。apt-get会自动处理依赖关系。
sudo apt-get install python-scrapy

文档实际上说:“不要使用Ubuntu提供的python-scrapy软件包,它们通常太旧且速度太慢,无法跟上最新的Scrapy。” - Dean Fenster

3
问题在于我需要通过命令sudo apt-get install libssl-dev来安装OpenSSL开发包。

仅翻译,不多说。 - Zulu

3

安装文档所述,您应该运行以下命令:

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

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接