Skip to main content
 首页 » 编程设计

python之如何在 Mac OS X 中为 python3 安装密码学

2025年05月04日15lautakyan007

执行pip3 install cryptography时, pip3报错:

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

我检查了 brew info openssl得到了答案:

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

现在的问题是:我怎么知道pip使用 clang 时将路径添加到相应的构建变量中编译cpp文件?

请您参考如下方法:

尝试安装 scrapy 我需要在 Mac OS El Capitan 上安装加密包。如密码学安装文档中所述

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