在OS X El Capitan上安装Scrapy

wil*_*ing 4 python scrapy

我试图在El Capitan上安装Scrapy但尚未成功.我使用时会发生这种情况pip install Scrapy:

#include <openssl/opensslv.h>

         ^

1 error generated.

error: command 'cc' failed with exit status 1

----------------------------------------
Cleaning up...
Command /<scrapy_project>/venv/bin/python -c "import setuptools, tokenize;__file__='/<scrapy_project>/venv/build/cryptography/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /var/folders/p6/jvf54l7d5c7dntzm6d3rfc3w0000gn/T/pip-D2QIZq-record/install-record.txt --single-version-externally-managed --compile --install-headers /<scrapy_project>/venv/include/site/python2.7 failed with error code 1 in /<scrapy_project>/venv/build/cryptography
Run Code Online (Sandbox Code Playgroud)

我的Xcode和Xcode命令工具是最新的.根据http://doc.scrapy.org/en/latest/intro/install.html#intro-install,我尝试使用和不使用自制程序的方法安装Scrapy

编辑:我做了以下事情:

  • brew install openssl && brew link openssl --force 根据Craicerjack的建议
  • pip install cryptography
  • pip install scrapy

一切都没有任何错误.但scrapy --version抛出此错误:

ImportError: dlopen(/<scrapy_project>/venv/lib/python2.7/site-packages/cryptography/hazmat/bindings/_openssl.so, 2): Symbol not found: _BIO_new_CMS
  Referenced from: /<scrapy_project>/venv/lib/python2.7/site-packages/cryptography/hazmat/bindings/_openssl.so
  Expected in: flat namespace
 in /<scrapy_project>/venv/lib/python2.7/site-packages/cryptography/hazmat/bindings/_openssl.so
Run Code Online (Sandbox Code Playgroud)

Cra*_*ack 5

这里的问题是安装Scrapy所需的依赖项

首先你应该升级到最新版本的pip:

pip install --upgrade pip
Run Code Online (Sandbox Code Playgroud)

如果这不起作用,建立加密并动态链接它:

brew install openssl
env LDFLAGS="-L$(brew --prefix openssl)/lib" CFLAGS="-I$(brew --prefix openssl)/include" pip install cryptography  
Run Code Online (Sandbox Code Playgroud)

有关安装的更多信息,请参阅加密文档

使用该命令可以解决其他问题

LDFLAGS="-L/usr/local/opt/openssl/lib" pip install cryptography --no-use-wheel
Run Code Online (Sandbox Code Playgroud)

但是,如果您的所有软件(最新的密钥和加密)都是最新的,那么这不是必需的.关于这个问题的更多信息可以在github上加密仓库中找到