[Python] magic.MagicException: no magic files loaded

Discussão em 'Python' iniciado por Stack, Março 7, 2025.

  1. Stack

    Stack Membro Participativo

    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.

    Continue reading...

Compartilhe esta Página