ahupp / python-magic

A python wrapper for libmagic
Other
2.65k stars 283 forks source link

ImportError: failed to find libmagic. Check your installation #278

Closed IgnatiusEzeani closed 1 year ago

IgnatiusEzeani commented 2 years ago

My installation could not find libmagic. Any suggestions?

ahupp commented 2 years ago

Could you share more information; platform, how you installed it, the error you're seeing, what you've tried to debug already?

wmazur-splunk commented 2 years ago

This PR may help :-) https://github.com/ahupp/python-magic/pull/279 In my case it occurred it's an issue with Apple M1 Silicone (I do not know how to fix it yet)

"mach-o file, but is an incompatible architecture (have (arm64), need (x86_64))"

0xDAV1D-1 commented 2 years ago

I ran into this problem on a Apple M1 as at least one other person above did. To fix it, I installed homebrew (https://brew.sh/) and then ran brew install libmagic

After that I was able to successfully import magic for my programs that needed them.

alejandroacho commented 1 year ago

But does it has any sense when you are running it into a docker container?

In my case I'm also working with a M1 macbook, but everything is containerized

melyux commented 1 year ago

Having this problem inside a Linux container on a Linux machine. Also had it on a Mac. Check out this issue for hundreds of people with this problem using another project that uses this project:

https://github.com/Yelp/elastalert/issues/1927

francisbrito commented 1 year ago

In case you're Anaconda using as your environment manager:

The command to install libmagic is:

conda install libmagic
kennethleungty commented 1 year ago

How to fix this for Windows and with pip?

KaczuH commented 1 year ago

This PR may help :-) #279 In my case it occurred it's an issue with Apple M1 Silicone (I do not know how to fix it yet)

"mach-o file, but is an incompatible architecture (have (arm64), need (x86_64))"

My coworker has the same issue (running on M1 Mac). Suprisingly i had no problems despite having M1 Mac myself.

What we think differs between our setups is that my colleague installed python via homebrew and i'm using pyenv,

FInally we've been able to force it to work after following instructions in: https://medium.com/mkdir-awesome/how-to-install-x86-64-homebrew-packages-on-apple-m1-macbook-54ba295230f

But does feel like workaround not proper solution

@ahupp PR #279 really could have saved us a lot of debugging.

ahupp commented 1 year ago

@KaczuH yeah swallowing was a bad call. I don't think there's anything else to do with this issue since it's a local install problem and once in python I'm not sure how to detect it. Closing issue, feel free to re-open if there's anything else to do.