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?


  • 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