简体   繁体   English

安装多个需要不同 LDFLAGS/CPPFLAGS 的 python 包(macOS Big Sur Apple Silicone)

[英]Installing multiple python packages that requires different LDFLAGS/CPPFLAGS (macOS Big Sur Apple Silicone)

When installing python requirements from requirements.txt file, there were several packages that required different values in LDFLAGS/CPPFLAGS.从 requirements.txt 文件安装 python 需求时,有几个包需要 LDFLAGS/CPPFLAGS 中的不同值。 first, I got this when installing mysql-client: ld: library not found for -lzstd I solved it by running the pip install like this:首先,我在安装 mysql-client 时得到了这个: ld: library not found for -lzstd我通过像这样运行 pip install 来解决它:

CPPFLAGS="-I/opt/homebrew/include" LDFLAGS="-L/opt/homebrew/lib" pip install mysqlclient

than, I had this issue when installing cryptography:比,我在安装加密时遇到了这个问题:

build/temp.macosx-10.14-arm64-3.8/_openssl.c:575:10: fatal error: 'openssl/opensslv.h' file not found
#include <openssl/opensslv.h>

Solved it by installing it like this:通过像这样安装它来解决它:

CPPFLAGS="-I/opt/homebrew/opt/openssl@1.1/include" LDFLAGS="-L/opt/homebrew/opt/openssl@1.1/lib" pip install cryptography

My question is - what is going on here?我的问题是 - 这里发生了什么? I want to keep LDFLAGS/CPPFLAGS values in my .zshrc but seems that for every package I need diferent values there??我想在我的 .zshrc 中保留 LDFLAGS/CPPFLAGS 值,但似乎对于每个包我都需要不同的值? When working on my old mac I remember that the values were在我的旧 Mac 上工作时,我记得这些值是

export LDFLAGS="-L/opt/homebrew/opt/mysql-client/lib"
export CPPFLAGS="-I/opt/homebrew/opt/mysql-client/include"

which are the values that are suggested to you by brew after you brew install mysql-client.这是 brew install mysql-client 后 brew 向您建议的值。

As long as they do not conflict with each other, you can put multiple directories in there with something like只要它们不相互冲突,您就可以将多个目录放入其中,例如

LDFLAGS='-L/opt/foo/lib -L/usr/local/bar/lib'

and ditto for CPPFLAGS. CPPFLAGS 也是如此。

However, personally I'd avoid putting LDFLAGS and CPPFLAGS in .zshrc — as you have found out, the required values often depend on the thing you are compiling, and setting them globally (and then inevitably forgetting about them) is likely to cause confusion at some point in the future.但是,就我个人而言,我会避免将 LDFLAGS 和 CPPFLAGS 放在 .zshrc 中——正如您所发现的,所需的值通常取决于您正在编译的内容,并且全局设置它们(然后不可避免地忘记它们)可能会引起混淆在未来的某个时候。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM