On OSX, I have installed python-magic
through pip
on a virtual env
.
I get a magic file not found error, when I do this,
import magic
print magic.Magic(mime=True).from_file("/opt/local/bin/python2.7")
And I get this
magic.MagicException: no magic files loaded
I tried with setting magic_file parameter and I still get it.
print magic.Magic(mime=True,
magic_file="/opt/local/share/misc/magic").from_file("/opt/local/bin/python2.7")
And yes, I have verified the magic file exists.
I use Python installed through macports.
EDIT: I tried the same thing with homebrew. Installed libmagic
through brew and installed
python-magic
. And the results are the same.
Ok, I posted this a while ago in the comments. Just adding it here to mark the question answered:
Ok. I figured this out. Versions 0.4.3 and above have a bug in them See github.com/ahupp/python-magic/issues/44. I could not install it from pip(did pip-review --interactive, it shows me there is version 0.4.6 but won't install it). Since the bug was fixed in version 0.4.6 I got the python-magic.egg from pypi and installed it with easy_install, and it works!!!