I'm currently developing a script called script.py that makes use of the libmagic package. I used homebrew (3.5.9) to install it via ZSH shell on an M1 Pro Mac.
As with any homebrew package installation, I used brew install libmagic and it installed successfully, but by the time I tried to import it to my program with import magic, the ModuleNotFoundError was thrown.
At first, I thought the module was not found because it was installed as a third party module, so I added the path to $PYTHONPATH and I verified it via printing each entries with sys.path. But, I still get the same error.
One assumption I made here is that the path I gave to $PYTHONPATH is where the magic module is located, but I think I have done something wrong here because the module search path clearly has the path I included so why is it still throwing the same error?
Clearly, the path listed in $PYTHONPATH was included as shown below, so why can't the module be found?

I'm suspecting that I'm not using the right directory for my $PYTHONPATH and most tutorials out there uses an Intel chip which has a different file structure than the one in M1 Pro. The packages installed in the M1 Pro are stored under /opt/homebrew/Cellar and I might have missed some important steps.
Anybody who has experienced similar problems, please show me the way. Thank you.



You can download the official version of libmagic module with these commands
or if u dont have pip installed install it by using these commands