Sergii V.
Sergii V.

Reputation: 311

pip fails to find brew installed libs with M1 chip

folks, with new M1 chip brew stores its libraries in the different location /opt/homebrew/ instead of /usr/local/.
And now when pip needs some packages installed by brew(in my case leveldb for plyvel)it's not able to find it until I use Rosetta brew version to put in the old directory: /usr/local/.
I've added eval "$(/opt/homebrew/bin/brew shellenv)" in my .zshrc to import brew-related vars and I thought it should do the thing but no lack.

Do you have any tips on how to handle this issue?

Upvotes: 2

Views: 1413

Answers (2)

Ture Pålsson
Ture Pålsson

Reputation: 6776

I don't know whether there is a Right Way to do this, but one way is to pass the necessary compiler flags as an environment variable:

CFLAGS="-I/opt/homebrew/include -L/opt/homebrew/lib" python3 -m pip install plyvel

Upvotes: 4

Sarang
Sarang

Reputation: 2713

The correct solution to this problem is to include homebrew path in LDFLAGS

export LDFLAGS=-L/opt/homebrew/lib/

and then run the pip command. It is best to add this to your bash / zsh profile (~/.bashrc or ~/.zshrc).

Upvotes: 0

Related Questions