簡體   English   中英

無法在 MacOs 中為 python2 安裝 pyopenssl

[英]Unable to install pyopenssl in MacOs for python2

我正在嘗試在 Mac OS 的 python2.7 中使用此運行 scrapy 命令:

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

但我收到此錯誤:

from OpenSSL._util import lib as pyOpenSSLlib
ImportError: No module named _util

當我嘗試安裝時

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

我怎樣才能解決這個問題?

您丟失或使用了舊版本的 openssl 包或使用舊版本的 pip。

  1. 在您的終端中,執行openssl version 如果已安裝,請執行brew upgrade openssl 如果未安裝,請執行brew install openssl
  2. 如果您使用的不是最新版本, pip install -U upgrade更新 pip - pip install -U upgrade
  3. 使用安裝pyopenssl pip install pyopenssl 如果安裝正確,請跳過步驟 4。
  4. 使用pyopenssl安裝包
    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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM