How to install cryptography for python3 in Mac OS

2019-06-01 16:50发布

When executing pip3 install cryptography, pip3 gives an error:

fatal error: 'openssl/aes.h' file not found
#include <openssl/aes.h>

1 error generated.
error: command '/usr/bin/clang' failed with exit status 1

I checked with brew info openssl and got the answer:

Generally there are no consequences of this for you. If you build your own software and it requires this formula, you'll need to add to your build variables:

LDFLAGS: -L/usr/local/opt/openssl/lib
CPPFLAGS: -I/usr/local/opt/openssl/include

The problem now is: how can I tell pip add the paths into corresponding build variables when it uses clang to compile cpp file?

标签: python macos pip
1条回答
够拽才男人
2楼-- · 2019-06-01 17:49

Trying to install the scrapy I need to install cryptography package on Mac OS El Capitan. As explained in Cryptography installation doc

env LDFLAGS="-L$(brew --prefix openssl)/lib" CFLAGS="-I$(brew --prefix openssl)/include" pip install cryptography

查看更多
登录 后发表回答