mac上安装scrapy框架

今天开始学习scrapy,按照学习文档的提示,在我的mac电脑终端输入如下命令:

pip install scrape

结果出现了如下错误:

clang -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/usr/local/var/pyenv/versions/2.7.11/include/python2.7 -c build/temp.macosx-10.11-x86_64-2.7/_openssl.c -o build/temp.macosx-10.11-x86_64-2.7/build/temp.macosx-10.11-x86_64-2.7/_openssl.o
    build/temp.macosx-10.11-x86_64-2.7/_openssl.c:423:10: fatal error: 'openssl/e_os2.h' file not found
    #include <openssl/e_os2.h>
             ^
    1 error generated.
    error: command 'clang' failed with exit status 1
    
    ----------------------------------------
Command "/usr/local/var/pyenv/versions/2.7.11/bin/python2.7 -u -c "import setuptools, tokenize;__file__='/private/var/folders/3p/7b_wv8x57bjg08f8mcrhtydh0000gn/T/pip-build-X2gKqb/cryptography/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /var/folders/3p/7b_wv8x57bjg08f8mcrhtydh0000gn/T/pip-nTqjDd-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /private/var/folders/3p/7b_wv8x57bjg08f8mcrhtydh0000gn/T/pip-build-X2gKqb/cryptography/

网上一番搜寻后(差不多花费了我2个小时),找到解决办法为:在终端输入如下命令:

env CRYPTOGRAPHY_OSX_NO_LINK_FLAGS=1 LDFLAGS="$(brew --prefix openssl)/lib/libssl.a $(brew --prefix openssl)/lib/libcrypto.a" CFLAGS="-I$(brew --prefix openssl)/include" pip install scrape

此后,安装成功。

    原文作者:盗花
    原文地址: https://www.jianshu.com/p/60bdc000c921
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞