Skip to content
Advertisement

Missing files for `magic` library on Windows

I need to get mime type for some files on windows, so i’ve installed python-magic (on 32-bit python 2.7.3).
It depends on unix magic library.
Author instructs to get regex2.dll, zlib1.dll and magic1.dll from gnuwin32 project. So i saved the files to a folder and added the folder to my system PATH.
Now when i execute magic methods, i get missing file exception:

JavaScript

DLLs are in the PATH, i tried debugging and magic1.dll is located correctly, but somewhere inside library throws an exception.
Inside the gnuwin32 package i’ve found magic and magic.mgc. I placed them to the same folder, and got WindowsError: [Error 126] on

JavaScript

This obviously happens because python tries to open magic file as dll, which is plain text. After adding .dll to filenames in the code i get the same magic.MagicException: could not find any magic files!.
What files am i missing?

UPDATE:

JavaScript

UPDATE 2 (SOLVED):

JavaScript

just had to specify file explicitly

Advertisement

Answer

Path to magic file has to be explicitly passed to the constructor.

JavaScript
User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement