typecode-libmagic
raw JSON → 5.39.210531 verified Fri May 01 auth: no python
A Scancode path provider plugin that downloads and provides a prebuilt native libmagic binary and its database for file type detection. Version 5.39.210531. Low release cadence; primarily used as a dependency within the ScanCode toolkit ecosystem.
pip install typecode-libmagic Common errors
error ModuleNotFoundError: No module named 'typecode_libmagic' ↓
cause Trying to import with hyphens instead of underscores. The installed package name uses hyphens but the import uses underscores.
fix
Install the package with pip install typecode-libmagic and then import it as from typecode_libmagic import ...
error AttributeError: module 'typecode_libmagic' has no attribute 'LibmagicPathProvider' ↓
cause Using an older version of the library where the class had a different name or location.
fix
Upgrade to the latest version: pip install --upgrade typecode-libmagic. Then use LibmagicPathProvider.
Warnings
gotcha Do not install typecode-libmagic directly unless you are building a ScanCode plugin environment. For general use, rely on typecode which pulls this plugin automatically. ↓
fix Install typecode instead: pip install typecode
breaking In versions prior to 1.0.0, the provider class was located in a different module. Update imports if upgrading from an older release. ↓
fix Use from typecode_libmagic import LibmagicPathProvider
deprecated The old method get_libmagic() is deprecated in favor of get_libmagic_path() which returns a path string. ↓
fix Replace provider.get_libmagic() with provider.get_libmagic_path()
Imports
- LibmagicPathProvider
from typecode_libmagic import LibmagicPathProvider
Quickstart
from typecode_libmagic import LibmagicPathProvider
provider = LibmagicPathProvider()
print(provider.get_libmagic_path())