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.<
As the python-magic problems seems to be quite common, here a working solution fo future googlers: After testing most solutions without altering the source-code, I found the following to get python-magic working out of the box:
Path to magic
file has to be explicitly passed to the constructor.
magic_object = magic.Magic(magic_file = 'path_to_magic_files/magic'))
For future google visitors: Another solution is setting the %MAGIC% enviroment variable in the systems setting to point to the magic file, for me it was:
"c:\Program Files (x86)\GnuWin32\share\misc\magic"
No need to hardcode the path in your program!