Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/python-2.7/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
无法在MacOs for python2中安装pyopenssl_Python_Python 2.7 - Fatal编程技术网

无法在MacOs for python2中安装pyopenssl

无法在MacOs for python2中安装pyopenssl,python,python-2.7,Python,Python 2.7,我试图在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.m

我试图在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
build/temp.macosx-10.13-intel-2.7/_openssl.c:493:10:致命错误:找不到“openssl/opensslv.h”文件
#包括
^~~~~~~~~~~~~~~~~~~~
生成1个错误。
错误:命令“cc”失败,退出状态为1
----------------------------------------
Command“/System/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python-c”导入setuptools,标记化__文件_uuu='/private/tmp/pip-build-v_oSaa/cryptography/setup.py';exec(compile(getattr(tokenize,'open',open)(uuu文件uu).read().replace('\r\n','\n'),uu文件uu,'exec'))“install--record/tmp/pip-A590v3-record/install-record.txt--外部管理的单一版本--compile--user”失败,错误代码为/private/tmp/pip-build-v\u-oSaa/cryptography

如何修复此问题?

您可能缺少或使用了较旧版本的openssl包,或者使用了较旧版本的pip

  • 在终端中,执行openssl版本。如果已安装,请执行
    brew升级openssl
    。如果未安装,请执行
    brew安装openssl
  • 如果未使用最新版本,请更新pip-
    pip安装-U升级
  • 使用
    pip安装pyopenssl
    安装pyopenssl。如果安装正确,请跳过步骤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”
  • 参考: