Python front end for libmagic(3) — uses ctypes to wrap libmagic for file type detection. Current version 0.4.1, last released 2016; requires libmagic (system library). Unmaintained; prefer `python-magic` for active development.
pip install file-magicVerified import paths — ran on the pinned version, not inferred.
Basic usage: create a magic cookie, load magic database, detect file type.
Use `python-magic` for new projects.
Install libmagic (e.g., apt-get install libmagic1 on Debian/Ubuntu).
Consider using `python-magic-bin` or `python-magic` with appropriate binary.
Uninstall both and reinstall only one: `pip uninstall file-magic python-magic python-magic-bin` then `pip install python-magic`.
Install libmagic: on Linux `sudo apt-get install libmagic1` (or equivalent), on macOS `brew install libmagic`.
Encode path if needed: `m.file(bytes(path, 'utf-8'))` or ensure string path works (usual).