python-magic icon indicating copy to clipboard operation
python-magic copied to clipboard

ImportError: failed to find libmagic. Check your installation

Open IgnatiusEzeani opened this issue 3 years ago • 3 comments

My installation could not find libmagic. Any suggestions?

IgnatiusEzeani avatar Aug 24 '22 21:08 IgnatiusEzeani

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

ahupp avatar Aug 25 '22 16:08 ahupp

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))"

wmazur-splunk avatar Aug 29 '22 12:08 wmazur-splunk

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.

0xDAV1D-1 avatar Sep 28 '22 13:09 0xDAV1D-1

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

alejandroacho avatar Feb 04 '23 22:02 alejandroacho

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

melyux avatar Feb 05 '23 23:02 melyux

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

The command to install libmagic is:

conda install libmagic

francisbrito avatar Mar 02 '23 20:03 francisbrito

How to fix this for Windows and with pip?

kennethleungty avatar Mar 03 '23 12:03 kennethleungty

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.

KaczuH avatar May 03 '23 12:05 KaczuH

@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.

ahupp avatar Aug 25 '23 18:08 ahupp