cryptography依赖安装报错

在MAC上安装Ansible 2.10.4时遇到cryptography库构建失败的问题,错误信息显示轮子构建错误。原因是缺少openssl的依赖。解决方法是通过brew安装openssl@1.1,并在.zshrc文件中添加环境变量以指定openssl的头文件和库文件路径。
摘要由CSDN通过智能技术生成

MAC 安装ansible 2.10.4,cryptography依赖安装报错

报错信息

...
Building wheels for collected packages: cryptography
  Building wheel for cryptography (PEP 517) ... error
  ERROR: Command errored out with exit status 1:
   command: /Users/dd/.pyenv/versions/3.9.0/bin/python3.9 /Users/dd/.pyenv/versions/3.9.0/lib/python3.9/site-packages/pip/_vendor/pep517/_in_process.py build_wheel /var/folders/xk/w026vg2115n487tm199n6v040000gn/T/tmpg5x46lcs
       cwd: /private/var/folders/xk/w026vg2115n487tm199n6v040000gn/T/pip-install-78moxgb3/cryptography
  Complete output (137 lines):
  running bdist_wheel
  running build
  running build_py
  creating build
  creating build/lib.macosx-11.0-x86_64-3.9
  creating build/lib.macosx-11.0-x86_64-3.9/cryptography
  copying src/cryptography/__init__.py -> build/lib.macosx-11.0-x86_64-3.9/cryptography
  copying src/cryptography/utils.py -> build/lib.macosx-11.0-x86_64-3.9/cryptography
  copying src/cryptography/__about__.py -> build/lib.macosx-11.0-x86_64-3.9/cryptography
  copying src/cryptography/exceptions.py -> build/lib.macosx-11.0-x86_64-3.9/cryptography
  copying src/cryptography/fernet.py -> build/lib.macosx-11.0-x86_64-3.9/cryptography
  creating build/lib.macosx-11.0-x86_64-3.9/cryptography/hazmat
  copying src/cryptography/hazmat/_der.py -> build/lib.macosx-11.0-x86_64-3.9/cryptography/hazmat
  copying src/cryptography/hazmat/__init__.py -> build/lib.macosx-11.0-x86_64-3.9/cryptography/hazmat
  copying src/cryptography/hazmat/_oid.py -> build/lib.macosx-11.0-x86_64-3.9/cryptography/hazmat
  creating build/lib.macosx-11.0-x86_64-3.9/cryptography/x509
  copying src/cryptography/x509/oid.py -> build/lib.macosx-11.0-x86_64-3.9/cryptography/x509
  copying src/cryptography/x509/ocsp.py -> build/lib.macosx-11.0-x86_64-3.9/cryptography/x509
  copying src/cryptography/x509/general_name.py -> build/lib.macosx-11.0-x86_64-3.9/cryptography/x509
  copying src/cryptography/x509/__init__.py -> build/lib.macosx-11.0-x86_64-3.9/cryptography/x509
  copying src/cryptography/x509/extensions.py -> build/lib.macosx-11.0-x86_64-3.9/cryptography/x509
  copying src/cryptography/x509/name.py -> build/lib.macosx-11.0-x86_64-3.9/cryptography/x509
  copying src/cryptography/x509/base.py -> build/lib.macosx-11.0-x86_64-3.9/cryptography/x509
  copying src/cryptography/x509/certificate_transparency.py -> build/lib.macosx-11.0-x86_64-3.9/cryptography/x509
  creating build/lib.macosx-11.0-x86_64-3.9/cryptography/hazmat/backends
  copying src/cryptography/hazmat/backends/interfaces.py -> build/lib.macosx-11.0-x86_64-3.9/cryptography/hazmat/backends
  copying src/cryptography/hazmat/backends/__init__.py -> build/lib.macosx-11.0-x86_64-3.9/cryptography/hazmat/backends
  creating build/lib.macosx-11.0-x86_64-3.9/cryptography/hazmat/primitives
  copying src/cryptography/hazmat/primitives/cmac.py -> build/lib.macosx-11.0-x86_64-3.9/cryptography/hazmat/primitives
  copying src/cryptography/hazmat/primitives/__init__.py -> build/lib.macosx-11.0-x86_64-3.9/cryptography/hazmat/primitives
  copying src/cryptography/hazmat/primitives/poly1305.py -> build/lib.macosx-11.0-x86_64-3.9/cryptography/hazmat/primitives
  copying src/cryptography/hazmat/primitives/constant_time.py -> build/lib.macosx-11.0-x86_64-3.9/cryptography/hazmat/primitives
  copying src/cryptography/hazmat/primitives/keywrap.py -> build/lib.macosx-11.0-x86_64-3.9/cryptography/hazmat/primitives
  copying src/cryptography/hazmat/primitives/hmac.py -> build/lib.macosx-11.0-x86_64-3.9/cryptography/hazmat/primitives
  copying src/cryptography/hazmat/primitives/hashes.py -> build/lib.macosx-11.0-x86_64-3.9/cryptography/hazmat/primitives
  copying src/cryptography/hazmat/primitives/padding.py -> build/lib.macosx-11.0-x86_64-3.9/cryptography/hazmat/primitives
  creating build/lib.macosx-11.0-x86_64-3.9/cryptography/hazmat/bindings
  copying src/cryptography/hazmat/bindings/__init__.py -> build/lib.macosx-11.0-x86_64-3.9/cryptography/hazmat/bindings
  creating build/lib.macosx-11.0-x86_64-3.9/cryptography/hazmat/backends/openssl
  copying src/cryptography/hazmat/backends/openssl/x448.py -> build/lib.macosx-11.0-x86_64-3.9/cryptography/hazmat/backends/openssl
  copying src/cryptography/hazmat/backends/openssl/backend.py -> build/lib.macosx-11.0-x86_64-3.9/cryptography/hazmat/backends/openssl
  copying src/cryptography/hazmat/backends/openssl/ec.py -> build/lib.macosx-11.0-x86_64-3.9/cryptography/hazmat/backends/openssl
  copying src/cryptography/hazmat/backends/openssl/ciphers.py -> build/lib.macosx-11.0-x86_64-3.9/cryptography/hazmat/backends/openssl
  copying src/cryptography/hazmat/backends/openssl/ocsp.py -> build/lib.macosx-11.0-x86_64-3.9/cryptography/hazmat/backends/openssl
  copying src/cryptography/hazmat/backends/openssl/x509.py -> build/lib.macosx-11.0-x86_64-3.9/cryptography/hazmat/backends/openssl
  copying src/cryptography/hazmat/backends/openssl/aead.py -> build/lib.macosx-11.0-x86_64-3.9/cryptography/hazmat/backends/openssl
  copying src/cryptography/hazmat/backends/openssl/encode_asn1.py -> build/lib.macosx-11.0-x86_64-3.9/cryptography/hazmat/backends/openssl
  copying src/cryptography/hazmat/backends/openssl/rsa.py -> build/lib.macosx-11.0-x86_64-3.9/cryptography/hazmat/backends/openssl
  copying src/cryptography/hazmat/backends/openssl/dh.py -> build/lib.macosx-11.0-x86_64-3.9/cryptography/hazmat/backends/openssl
  copying src/cryptography/hazmat/backends/openssl/cmac.py -> build/lib.macosx-11.0-x86_64-3.9/cryptography/hazmat/backends/openssl
  copying src/cryptography/hazmat/backends/openssl/__init__.py -> build/lib.macosx-11.0-x86_64-3.9/cryptography/hazmat/backends/openssl
  copying src/cryptography/hazmat/backends/openssl/utils.py -> build/lib.macosx-11.0-x86_64-3.9/cryptography/hazmat/backends/openssl
  copying src/cryptography/hazmat/backends/openssl/poly1305.py -> build/lib.macosx-11.0-x86_64-3.9/cryptography/hazmat/backends/openssl
  copying src/cryptography/hazmat/backends/openssl/ed25519.py -> build/lib.macosx-11.0-x86_64-3.9/cryptography/hazmat/backends/openssl
  copying src/cryptography/hazmat/backends/openssl/dsa.py -> build/lib.macosx-11.0-x86_64-3.9/cryptography/hazmat/backends/openssl
  copying src/cryptography/hazmat/backends/openssl/decode_asn1.py -> build/lib.macosx-11.0-x86_64-3.9/cryptography/hazmat/backends/openssl
  copying src/cryptography/hazmat/backends/openssl/hmac.py -> build/lib.macosx-11.0-x86_64-3.9/cryptography/hazmat/backends/openssl
  copying src/cryptography/hazmat/backends/openssl/ed448.py -> build/lib.macosx-11.0-x86_64-3.9/cryptography/hazmat/backends/openssl
  copying src/cryptography/hazmat/backends/openssl/x25519.py -> build/lib.macosx-11.0-x86_64-3.9/cryptography/hazmat/backends/openssl
  copying src/cryptography/hazmat/backends/openssl/hashes.py -> build/lib.macosx-11.0-x86_64-3.9/cryptography/hazmat/backends/openssl
  creating build/lib.macosx-11.0-x86_64-3.9/cryptography/hazmat/primitives/kdf
  copying src/cryptography/hazmat/primitives/kdf/__init__.py -> build/lib.macosx-11.0-x86_64-3.9/cryptography/hazmat/primitives/kdf
  copying src/cryptography/hazmat/primitives/kdf/scrypt.py -> build/lib.macosx-11.0-x86_64-3.9/cryptography/hazmat/primitives/kdf
  copying src/cryptography/hazmat/primitives/kdf/pbkdf2.py -> build/lib.macosx-11.0-x86_64-3.9/cryptography/hazmat/primitives/kdf
  copying src/cryptography/hazmat/primitives/kdf/hkdf.py -> build/lib.macosx-11.0-x86_64-3.9/cryptography/hazmat/primitives/kdf
  copying src/cryptography/hazmat/primitives/kdf/x963kdf.py -> build/lib.macosx-11.0-x86_64-3.9/cryptography/hazmat/primitives/kdf
  copying src/cryptography/hazmat/primitives/kdf/kbkdf.py -> build/lib.macosx-11.0-x86_64-3.9/cryptography/hazmat/primitives/kdf
  copying src/cryptography/hazmat/primitives/kdf/concatkdf.py -> build/lib.macosx-11.0-x86_64-3.9/cryptography/hazmat/primitives/kdf
  creating build/lib.macosx-11.0-x86_64-3.9/cryptography/hazmat/primitives/twofactor
  copying src/cryptography/hazmat/primitives/twofactor/totp.py -> build/lib.macosx-11.0-x86_64-3.9/cryptography/hazmat/primitives/twofactor
  copying src/cryptography/hazmat/primitives/twofactor/__init__.py -> build/lib.macosx-11.0-x86_64-3.9/cryptography/hazmat/primitives/twofactor
  copying src/cryptography/hazmat/primitives/twofactor/hotp.py -> build/lib.macosx-11.0-x86_64-3.9/cryptography/hazmat/primitives/twofactor
  copying src/cryptography/hazmat/primitives/twofactor/utils.py -> build/lib.macosx-11.0-x86_64-3.9/cryptography/hazmat/primitives/twofactor
  creating build/lib.macosx-11.0-x86_64-3.9/cryptography/hazmat/primitives/serialization
  copying src/cryptography/hazmat/primitives/serialization/__init__.py -> build/lib.macosx-11.0-x86_64-3.9/cryptography/hazmat/primitives/serialization
  copying src/cryptography/hazmat/primitives/serialization/pkcs12.py -> build/lib.macosx-11.0-x86_64-3.9/cryptography/hazmat/primitives/serialization
  copying src/cryptography/hazmat/primitives/serialization/pkcs7.py -> build/lib.macosx-11.0-x86_64-3.9/cryptography/hazmat/primitives/serialization
  copying src/cryptography/hazmat/primitives/serialization/ssh.py -> build/lib.macosx-11.0-x86_64-3.9/cryptography/hazmat/primitives/serialization
  copying src/cryptography/hazmat/primitives/serialization/base.py -> build/lib.macosx-11.0-x86_64-3.9/cryptography/hazmat/primitives/serialization
  creating build/lib.macosx-11.0-x86_64-3.9/cryptography/hazmat/primitives/ciphers
  copying src/cryptography/hazmat/primitives/ciphers/algorithms.py -> build/lib.macosx-11.0-x86_64-3.9/cryptography/hazmat/primitives/ciphers
  copying src/cryptography/hazmat/primitives/ciphers/aead.py -> build/lib.macosx-11.0-x86_64-3.9/cryptography/hazmat/primitives/ciphers
  copying src/cryptography/hazmat/primitives/ciphers/__init__.py -> build/lib.macosx-11.0-x86_64-3.9/cryptography/hazmat/primitives/ciphers
  copying src/cryptography/hazmat/primitives/ciphers/modes.py -> build/lib.macosx-11.0-x86_64-3.9/cryptography/hazmat/primitives/ciphers
  copying src/cryptography/hazmat/primitives/ciphers/base.py -> build/lib.macosx-11.0-x86_64-3.9/cryptography/hazmat/primitives/ciphers
  creating build/lib.macosx-11.0-x86_64-3.9/cryptography/hazmat/primitives/asymmetric
  copying src/cryptography/hazmat/primitives/asymmetric/x448.py -> build/lib.macosx-11.0-x86_64-3.9/cryptography/hazmat/primitives/asymmetric
  copying src/cryptography/hazmat/primitives/asymmetric/ec.py -> build/lib.macosx-11.0-x86_64-3.9/cryptography/hazmat/primitives/asymmetric
  copying src/cryptography/hazmat/primitives/asymmetric/rsa.py -> build/lib.macosx-11.0-x86_64-3.9/cryptography/hazmat/primitives/asymmetric
  copying src/cryptography/hazmat/primitives/asymmetric/dh.py -> build/lib.macosx-11.0-x86_64-3.9/cryptography/hazmat/primitives/asymmetric
  copying src/cryptography/hazmat/primitives/asymmetric/__init__.py -> build/lib.macosx-11.0-x86_64-3.9/cryptography/hazmat/primitives/asymmetric
  copying src/cryptography/hazmat/primitives/asymmetric/utils.py -> build/lib.macosx-11.0-x86_64-3.9/cryptography/hazmat/primitives/asymmetric
  copying src/cryptography/hazmat/primitives/asymmetric/ed25519.py -> build/lib.macosx-11.0-x86_64-3.9/cryptography/hazmat/primitives/asymmetric
  copying src/cryptography/hazmat/primitives/asymmetric/dsa.py -> build/lib.macosx-11.0-x86_64-3.9/cryptography/hazmat/primitives/asymmetric
  copying src/cryptography/hazmat/primitives/asymmetric/ed448.py -> build/lib.macosx-11.0-x86_64-3.9/cryptography/hazmat/primitives/asymmetric
  copying src/cryptography/hazmat/primitives/asymmetric/x25519.py -> build/lib.macosx-11.0-x86_64-3.9/cryptography/hazmat/primitives/asymmetric
  copying src/cryptography/hazmat/primitives/asymmetric/padding.py -> build/lib.macosx-11.0-x86_64-3.9/cryptography/hazmat/primitives/asymmetric
  creating build/lib.macosx-11.0-x86_64-3.9/cryptography/hazmat/bindings/openssl
  copying src/cryptography/hazmat/bindings/openssl/__init__.py -> build/lib.macosx-11.0-x86_64-3.9/cryptography/hazmat/bindings/openssl
  copying src/cryptography/hazmat/bindings/openssl/_conditional.py -> build/lib.macosx-11.0-x86_64-3.9/cryptography/hazmat/bindings/openssl
  copying src/cryptography/hazmat/bindings/openssl/binding.py -> build/lib.macosx-11.0-x86_64-3.9/cryptography/hazmat/bindings/openssl
  running egg_info
  writing src/cryptography.egg-info/PKG-INFO
  writing dependency_links to src/cryptography.egg-info/dependency_links.txt
  writing requirements to src/cryptography.egg-info/requires.txt
  writing top-level names to src/cryptography.egg-info/top_level.txt
  reading manifest file 'src/cryptography.egg-info/SOURCES.txt'
  reading manifest template 'MANIFEST.in'
  no previously-included directories found matching 'docs/_build'
  warning: no previously-included files found matching 'vectors'
  warning: no previously-included files matching '*' found under directory 'vectors'
  warning: no previously-included files found matching '.travis.yml'
  warning: no previously-included files found matching '.travis'
  warning: no previously-included files matching '*' found under directory '.travis'
  warning: no previously-included files matching '*' found under directory '.github'
  warning: no previously-included files found matching 'release.py'
  warning: no previously-included files found matching '.coveragerc'
  warning: no previously-included files found matching 'codecov.yml'
  warning: no previously-included files found matching 'dev-requirements.txt'
  warning: no previously-included files found matching 'rtd-requirements.txt'
  warning: no previously-included files found matching 'tox.ini'
  warning: no previously-included files matching '*' found under directory '.zuul.d'
  warning: no previously-included files matching '*' found under directory '.zuul.playbooks'
  writing manifest file 'src/cryptography.egg-info/SOURCES.txt'
  running build_ext
  generating cffi module 'build/temp.macosx-11.0-x86_64-3.9/_padding.c'
  creating build/temp.macosx-11.0-x86_64-3.9
  generating cffi module 'build/temp.macosx-11.0-x86_64-3.9/_openssl.c'
  building '_openssl' extension
  creating build/temp.macosx-11.0-x86_64-3.9/build
  creating build/temp.macosx-11.0-x86_64-3.9/build/temp.macosx-11.0-x86_64-3.9
  clang -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include -I/Users/dd/.pyenv/versions/3.9.0/include/python3.9 -c build/temp.macosx-11.0-x86_64-3.9/_openssl.c -o build/temp.macosx-11.0-x86_64-3.9/build/temp.macosx-11.0-x86_64-3.9/_openssl.o -Wconversion -Wno-error=sign-conversion
  build/temp.macosx-11.0-x86_64-3.9/_openssl.c:575:10: fatal error: 'openssl/opensslv.h' file not found
  #include <openssl/opensslv.h>
           ^~~~~~~~~~~~~~~~~~~~
  1 error generated.
  error: command '/usr/bin/clang' failed with exit code 1
  ----------------------------------------
  ERROR: Failed building wheel for cryptography
Failed to build cryptography
ERROR: Could not build wheels for cryptography which use PEP 517 and cannot be installed directly

解决办法

brew install openssl@1.1
## >> ~/.zshrc
export CPPFLAGS=-I/usr/local/opt/openssl/include
export LDFLAGS=-L/usr/local/opt/openssl/lib
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值