无法在MacOS上为Python2安装pyopenssl

2024-10-03 00:30:54 发布

您现在位置:Python中文网/ 问答频道 /正文

在Mac 7.7中用这个命令运行

cmdline.execute("scrapy crawl pornHubSpider".split())

但我收到了这个错误:

^{pr2}$

当我尝试安装

sudo pip install pyopenssl --user --upgrade

我得到:

build/temp.macosx-10.13-intel-2.7/_openssl.c:493:10: fatal error: 'openssl/opensslv.h' file not found
    #include <openssl/opensslv.h>
             ^~~~~~~~~~~~~~~~~~~~
    1 error generated.
    error: command 'cc' failed with exit status 1

    ----------------------------------------
    Command "/System/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python -c "import setuptools, tokenize;__file__='/private/tmp/pip-build-v_oSaa/cryptography/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-A590v3-record/install-record.txt --single-version-externally-managed --compile --user" failed with error code 1 in /private/tmp/pip-build-v_oSaa/cryptography

我该怎么解决这个问题?


Tags: installpipbuildwitherrorprivaterecordtmp
1条回答
网友
1楼 · 发布于 2024-10-03 00:30:54

您可能丢失或使用旧版本的openssl包,或使用旧版本的pip。在

  1. 在终端中,执行openssl version。如果已安装,请执行brew upgrade openssl。如果未安装,请执行brew install openssl
  2. 如果不使用最新版本,请更新pip-pip install -U upgrade。在
  3. 使用pip install pyopenssl安装pyopenssl。如果安装正确,跳过步骤4。在
  4. 使用
    pip install pyopenssl global-option=build_ext global-option="-L/usr/local/opt/openssl/lib" global-option="-I/usr/local/opt/openssl/include" 参考号:https://github.com/pyca/cryptography/issues/3489

相关问题 更多 >