pylibmagic
scikit-build project with CMake for compiling libmagic
Decision gist · record as of 2026-08-14
Yes, if you need to resolve libmagic import errors or distribute applications without system dependencies. The permissive license, active maintenance, and platform-specific wheels make it a straightforward solution to a real problem. The gap since the last release (2023-10-19) is worth verifying against your target Python and platform before production use.AI-flagged interpretation of the facts on this page — verify before relying
Before you install
- Requires Python 3.7 or later; platform-specific wheels available for macOS (Intel and ARM), Linux (glibc and musl), and aarch64 architectures.
- Medium install friction due to platform-specific wheels across macOS (x86_64 and arm64), Linux (x86_64 and aarch64), and musl variants.
- Repository is active with recent commits and stable maintenance.
License · maintenance · safety
permissive license (permissive) — Permissive BSD license allows commercial and private use without restriction; no copyleft obligations.
last release 2023-10-19 (1030 days) · last repo commit 2026-08-13 · 12 stars
0 known vulnerabilities (OSV.dev, 2026-08-14) · 330,454 downloads/mo, #7,536 on PyPI
Alternatives
Verify before relying
$ python3 -m pip install pylibmagic
import pylibmagic
import importlib-resources
import typing-extensions- Whether pylibmagic works correctly as a drop-in solution for the libmagic import error described in the documentation.
- Performance characteristics and feature compatibility with system-installed libmagic.
- Real-world success rate in containerized or CI/CD environments where system dependencies are unavailable.
What it is and what it does
pylibmagic is a minimal Python package that bundles pre-compiled libmagic libraries and registers them so they become available to dependent packages. It ships compiled binaries for multiple platforms (macOS, Linux, musl) and architectures using CMake and scikit-build, addressing the common ImportError that occurs when libmagic is not installed on the system.
The package is designed as a lightweight shim: install it, and the bundled libraries become available. It depends only on importlib-resources and typing-extensions, keeping the footprint minimal. It supports Python 3.7 through 3.12 and is classified as Beta-stage software.
Use it for
- Deploying applications in containerized or CI/CD environments where system package managers are unavailable or restricted.
- Distributing Python applications that need file-type detection without requiring end-users to install system libraries.
- Cross-platform development where developers use different operating systems and want consistent library availability.
- Scientific or research workflows that depend on file-type detection in sandboxed or minimal-dependency environments.
Worth the install?
AI-flagged interpretation of the facts on this page. Verify before relying on it.
Yes, if you need to resolve libmagic import errors or distribute applications without system dependencies.
The permissive license, active maintenance, and platform-specific wheels make it a straightforward solution to a real problem. The gap since the last release (2023-10-19) is worth verifying against your target Python and platform before production use.
Install
pylibmagic on PyPI
Before you install
Medium install friction due to platform-specific wheels across macOS (x86_64 and arm64), Linux (x86_64 and aarch64), and musl variants. Repository is active with recent commits and stable maintenance.
Requires Python 3.7 or later; platform-specific wheels available for macOS (Intel and ARM), Linux (glibc and musl), and aarch64 architectures.
License in practice
Permissive BSD license allows commercial and private use without restriction; no copyleft obligations.
Quickstart
$ python3 -m pip install pylibmagic
import pylibmagic
import importlib-resources
import typing-extensions
Verify before relying
- Whether pylibmagic works correctly as a drop-in solution for the libmagic import error described in the documentation.
- Performance characteristics and feature compatibility with system-installed libmagic.
- Real-world success rate in containerized or CI/CD environments where system dependencies are unavailable.
Package facts
| License | permissive license permissive |
| Python support | Supports the current Python release >=3.7 |
| Install friction | Medium. Platform-specific wheel |
| Runtime dependencies | 2 packagesimportlib-resourcestyping-extensions |
| Maintenance | Actively maintained 1,030 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 330,454 / month, #7,536 on PyPI 30-day window, as of 2026-08-14 |
| Known vulnerabilities | None known OSV.dev, checked 2026-08-14 |
| Classifiers | Development Status :: 4 - BetaIntended Audience :: DevelopersIntended Audience :: Science/ResearchLicense :: OSI Approved :: BSD LicenseOperating System :: OS IndependentProgramming Language :: PythonProgramming Language :: Python :: 3Programming Language :: Python :: 3 :: OnlyProgramming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.7Programming Language :: Python :: 3.8Programming Language :: Python :: 3.9Topic :: Scientific/Engineering |
Evidence: pylibmagic-0.5.0-py3-none-macosx_10_9_x86_64.whl; pylibmagic-0.5.0-py3-none-macosx_11_0_arm64.whl; pylibmagic-0.5.0-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl; pylibmagic-0.5.0-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl; pylibmagic-0.5.0-py3-none-musllinux_1_1_aarch64.whl; pylibmagic-0.5.0-py3-none-musllinux_1_1_x86_64.whl
Tags
Let your AI agent find packages like this
Example. Real query, live index.
You found this page by searching. An agent finds it by wishing: SkillFed indexes 14,416 PyPI packages by what they can do, searchable in plain language.
wish › “libmagic python bundled”
- pylibmagicProvides pre-compiled libmagic libraries bundled with Python, solving…
- typecodeDetects file types and MIME types using libmagic and Pygments, with…
- typecode-libmagicProvides a prebuilt native libmagic binary and database as a ScanCode…
Give your agent the search over MCP, or paste the wish link into any chat.
More Scientific/Engineering packages
NumPy provides an N-dimensional array object and a comprehensive suite of mathematical, linear algebra, Fourier transform, and random number functions for scientific computing in Python.
pandas provides fast, flexible data structures (Series and DataFrame) for loading, cleaning, transforming, and analyzing labeled or relational data in Python.
scipy provides numerical algorithms for mathematics, science, and engineering—including optimization, integration, linear algebra, Fourier transforms, signal and image processing, and ODE solvers—built on numpy arrays.
scikit-learn provides a comprehensive Python library for supervised and unsupervised machine learning, including classification, regression, clustering, dimensionality reduction, and model evaluation tools built on NumPy and SciPy.
Install it if you need to train, evaluate, or deploy supervised or unsupervised learning models.
dill extends Python's pickle module to serialize and deserialize a much wider range of Python objects, including functions, lambdas, classes, and interpreter sessions, to byte streams for storage or network transmission.
Multiprocess is an enhanced fork of Python's standard multiprocessing library that uses dill for better serialization, allowing you to spawn processes with a threading-like API and share complex objects between them.
Install it if you use multiprocessing and encounter pickle serialization limits with lambdas or complex objects.
See also python-magic-bin · python-magic · file-magic · typecode-libmagic · puremagic · libmagic · libuuu · scikit-build · typecode · epicscorelibs