Python-magic installation error - ImportError: failed to find libmagic
Asked Answered
E

5

11

I am trying to install python-magic for Windows and I have followed all the instructions in https://github.com/ahupp/python-magic and repeated the process several times but I am still getting this error:

ImportError: failed to find libmagic. Check your installation

I have magic1.dll (along with the two other files the docs specified) in C:\Windows\System32 so I am not sure what the issue is. I would appreciate any help or workarounds.

Eec answered 19/8, 2013 at 15:55 Comment(0)
E
3

The below original answer is now outdated. Please simply follow the instructions denoted under the "dependencies" section.


ORIGINAL ANSWER:

I was able to solve this problem by moving the 3 files from GNUWin32 project to a separate directory (not the \system32 directory the docs suggest) and adding them to the PATH environment variable

Eec answered 23/8, 2013 at 17:45 Comment(2)
which files? where did you put them?Padus
I think this answer is outdated now. There used to be 3 files you had to manually deal with. now you should just follow the directions under "Dependencies"Eec
S
9

Go here and download the file "python_magic_bin-0.4.14-py2.py3-none-win32.whl", then

pip install python_magic_bin-0.4.14-py2.py3-none-win32.whl

now python-magic works

enter image description here

Stubble answered 5/12, 2017 at 4:34 Comment(4)
THIS. You don't need to install Cygwin, either.Susi
the amd64 package on Win10 ... obviously ...Internalize
@user7660047, where is the problem?Stubble
Did not help in my case. It says "Requirement already satisfied" but still won't work. Note that I had to use the amd64 package on Win10, the win32 didn''t work at all.Trilley
A
9

I know this is a Windows question, but i wanted to share a Debian solution:

apt-get install libmagic-dev

Kind regards.

Annular answered 20/2, 2020 at 8:19 Comment(2)
Why do you post a debian solution if this is windows question?Slothful
Because people who are looking for solutions on their Linux questions still find this page on web searches, like me.Pothole
E
3

The below original answer is now outdated. Please simply follow the instructions denoted under the "dependencies" section.


ORIGINAL ANSWER:

I was able to solve this problem by moving the 3 files from GNUWin32 project to a separate directory (not the \system32 directory the docs suggest) and adding them to the PATH environment variable

Eec answered 23/8, 2013 at 17:45 Comment(2)
which files? where did you put them?Padus
I think this answer is outdated now. There used to be 3 files you had to manually deal with. now you should just follow the directions under "Dependencies"Eec
L
3

Follow the below steps.

  1. go to > https://github.com/pidydx/libmagicwin64
  2. download the 3 files (dll's) except readme.md file
  3. Drop the 3 files (dlls ) in C:\Windows\System32 and python magic will import correctly.
Lagunas answered 28/6, 2021 at 14:44 Comment(1)
I am getting "ImportError: failed to find libmagic. Check your installation", using PyCharm.Trilley
M
0

Installing Cygwin with libmagic libary and installing the most recent version of the module from Github solves this problem.

At the time this question was asked, https://github.com/ahupp/python-magic probably didn't support cygmagic-1.dll.

Misdoing answered 19/8, 2013 at 15:55 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.