OSX El Capitan python install cryptography fail
我试过了
sudo pip安装密码学
并且错误消息是
Collecting cryptography
Using cached cryptography-1.3.2-cp27-none-macosx_10_6_intel.whl
Requirement already satisfied (use --upgrade to upgrade): cffi>=1.4.1 in /Library/Python/2.7/site-packages (from cryptography)
Requirement already satisfied (use --upgrade to upgrade): pyasn1>=0.1.8 in /Library/Python/2.7/site-packages (from cryptography)
Collecting setuptools>=11.3 (from cryptography)
Using cached setuptools-21.0.0-py2.py3-none-any.whl
Requirement already satisfied (use --upgrade to upgrade): six>=1.4.1 in /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python (from cryptography)
Requirement already satisfied (use --upgrade to upgrade): idna>=2.0 in /Library/Python/2.7/site-packages (from cryptography)
Requirement already satisfied (use --upgrade to upgrade): ipaddress in /Library/Python/2.7/site-packages (from cryptography)
Requirement already satisfied (use --upgrade to upgrade): enum34 in /Library/Python/2.7/site-packages (from cryptography)
Requirement already satisfied (use --upgrade to upgrade): pycparser in /Library/Python/2.7/site-packages (from cffi>=1.4.1->cryptography)
Installing collected packages: setuptools, cryptography
Found existing installation: setuptools 1.1.6
Uninstalling setuptools-1.1.6:
Exception:
Traceback (most recent call last):
File"/Library/Python/2.7/site-packages/pip/basecommand.py", line 215, in main
status = self.run(options, args)
File"/Library/Python/2.7/site-packages/pip/commands/install.py", line 317, in run
prefix=options.prefix_path,
File"/Library/Python/2.7/site-packages/pip/req/req_set.py", line 736, in install
requirement.uninstall(auto_confirm=True)
File"/Library/Python/2.7/site-packages/pip/req/req_install.py", line 742, in uninstall
paths_to_remove.remove(auto_confirm)
File"/Library/Python/2.7/site-packages/pip/req/req_uninstall.py", line 115, in remove
renames(path, new_path)
File"/Library/Python/2.7/site-packages/pip/utils/init.py", line 267, in renames
shutil.move(old, new)
File"/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 299, in move
copytree(src, real_dst, symlinks=True)
File"/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 208, in copytree
raise Error, errors
Error: [('/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/_markerlib/init.py', '/tmp/pip-p7Ywro-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/_markerlib/init.py',"[Errno 1] Operation not permitted: '/tmp/pip-p7Ywro-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/_markerlib/init.py'"), ('/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/_markerlib/init.pyc', '/tmp/pip-p7Ywro-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/_markerlib/init.pyc',"[Errno 1] Operation not permitted: '/tmp/pip-p7Ywro-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/_markerlib/init.pyc'"), ('/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/_markerlib/markers.py', '/tmp/pip-p7Ywro-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/_markerlib/markers.py',"[Errno 1] Operation not permitted: '/tmp/pip-p7Ywro-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/_markerlib/markers.py'"), ('/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/_markerlib/markers.pyc', '/tmp/pip-p7Ywro-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/_markerlib/markers.pyc',"[Errno 1] Operation not permitted: '/tmp/pip-p7Ywro-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/_markerlib/markers.pyc'"), ('/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/_markerlib', '/tmp/pip-p7Ywro-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/_markerlib',"[Errno 1] Operation not permitted: '/tmp/pip-p7Ywro-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/_markerlib'")]
然后我搜索了一些帖子并尝试了
brew install pkg-config libffi openssl
Warning: pkg-config-0.28 already installed
Warning: libffi-3.0.13 already installed
Warning: openssl-1.0.2d_1 already installed
和
CFLAGS =" - I / usr / local / opt / openssl / include"sudo pip install cryptography == 0.8
我收到此错误消息:
src/cryptography/hazmat/bindings/pycache/_Cryptography_cffi_f3e4673fx399b1113.c:217:10: fatal error: 'openssl/aes.h' file not found
#include
^
1 error generated.
error: command 'cc' failed with exit status 1Command"/usr/bin/python -u -c"import setuptools, tokenize;file='/private/tmp/pip-build-MxT6op/cryptography/setup.py';exec(compile(getattr(tokenize, 'open', open)(file).read().replace('
', '
'), file, 'exec'))" install --record /tmp/pip-G6b8Y_-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /private/tmp/pip-build-MxT6op/cryptography/
我也试过了
brew install pkg-config libffi openssl
env LDFLAGS =" - L $(brew --prefix openssl)/ lib"CFLAGS =" - I $(brew --prefix openssl)/ include"pip install cryptography
得到了这个
Found existing installation: setuptools 1.1.6
Uninstalling setuptools-1.1.6:
Exception:
Traceback (most recent call last):
File"/Library/Python/2.7/site-packages/pip/basecommand.py", line 215, in main
status = self.run(options, args)
File"/Library/Python/2.7/site-packages/pip/commands/install.py", line 317, in run
prefix=options.prefix_path,
File"/Library/Python/2.7/site-packages/pip/req/req_set.py", line 736, in install
requirement.uninstall(auto_confirm=True)
File"/Library/Python/2.7/site-packages/pip/req/req_install.py", line 742, in uninstall
paths_to_remove.remove(auto_confirm)
File"/Library/Python/2.7/site-packages/pip/req/req_uninstall.py", line 115, in remove
renames(path, new_path)
File"/Library/Python/2.7/site-packages/pip/utils/init.py", line 267, in renames
shutil.move(old, new)
File"/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 299, in move
copytree(src, real_dst, symlinks=True)
File"/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 208, in copytree
raise Error, errors
Error: [('/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/_markerlib/init.py', '/tmp/pip-aYpqDT-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/_markerlib/init.py',"[Errno 1] Operation not permitted: '/tmp/pip-aYpqDT-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/_markerlib/init.py'"), ('/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/_markerlib/init.pyc', '/tmp/pip-aYpqDT-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/_markerlib/init.pyc',"[Errno 1] Operation not permitted: '/tmp/pip-aYpqDT-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/_markerlib/init.pyc'"), ('/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/_markerlib/markers.py', '/tmp/pip-aYpqDT-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/_markerlib/markers.py',"[Errno 1] Operation not permitted: '/tmp/pip-aYpqDT-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/_markerlib/markers.py'"), ('/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/_markerlib/markers.pyc', '/tmp/pip-aYpqDT-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/_markerlib/markers.pyc',"[Errno 1] Operation not permitted: '/tmp/pip-aYpqDT-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/_markerlib/markers.pyc'"), ('/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/_markerlib', '/tmp/pip-aYpqDT-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/_markerlib',"[Errno 1] Operation not permitted: '/tmp/pip-aYpqDT-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/_markerlib'")]
请帮我解决这个问题。 非常感谢。
我通过以下命令得到了这个修复:
1 2 3 4 5 6 | brew reinstall python ARCHFLAGS="-arch x86_64" LDFLAGS="-L/usr/local/opt/openssl/lib" \ CFLAGS="-I/usr/local/opt/openssl/include" pip install cryptography brew link —force openssl |
对我有用的是:
1 | sudo brew reinstall python |
在Mac OS El Capitan上安装加密包。 正如Cryptography安装文档中所述
env LDFLAGS =" - L $(brew --prefix openssl)/ lib"CFLAGS =" - I $(brew --prefix openssl)/ include"pip install cryptography