我尝试在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
我的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
答案 0 :(得分:5)
这里的问题是安装Scrapy所需的依赖项
首先你应该升级到最新版本的pip:
pip install --upgrade pip
如果这不起作用,建立加密并动态链接它:
brew install openssl
env LDFLAGS="-L$(brew --prefix openssl)/lib" CFLAGS="-I$(brew --prefix openssl)/include" pip install cryptography
有关安装的更多信息,请参阅cryptography docs
使用命令
可以解决其他问题LDFLAGS="-L/usr/local/opt/openssl/lib" pip install cryptography --no-use-wheel
但是,如果您的所有软件(最新的密码和加密)都是最新的,那么这不是必需的。有关此问题的更多信息,请参阅cryptography repo on github
中的问题