{"id":27485,"library":"typecode","title":"typecode","description":"Comprehensive filetype and mimetype detection using libmagic and Pygments. Current version: 30.2.0. Regular releases every few months.","status":"active","version":"30.2.0","language":"python","source_language":"en","source_url":"https://github.com/aboutcode-org/typecode","tags":["filetype","mimetype","detection","libmagic","pygments"],"install":[{"cmd":"pip install typecode","lang":"bash","label":"Standard install"},{"cmd":"pip install typecode[system_provided]","lang":"bash","label":"With system libmagic"}],"dependencies":[{"reason":"Optional for using system libmagic on mac/linux arm","package":"typecode-libmagic-system-provided","optional":true}],"imports":[{"note":"TypeCode is a top-level export; incorrect import caused by outdated docs.","wrong":"from typecode.type import TypeCode","symbol":"TypeCode","correct":"from typecode import TypeCode"}],"quickstart":{"code":"from typecode import TypeCode\n\n# Initialize with a file path\ntc = TypeCode('/path/to/file')\nprint(tc.mimetype)\nprint(tc.filetype)","lang":"python","description":"Quickstart: create a TypeCode object from a file path and access mime/file types."},"warnings":[{"fix":"pip install typecode[system_provided] OR install libmagic via apt/brew/etc.","message":"libmagic must be installed on the system or via the typecode-libmagic-system-provided plugin. On macOS/ARM Linux, you must install the 'system_provided' extra or have libmagic available via package manager.","severity":"gotcha","affected_versions":">=30.2.0"},{"fix":"Replace pkg_resources references with importlib.metadata for resource access.","message":"pkg_resources usage was removed in v30.1.0. Code relying on pkg_resources to access typecode resources may break. Use importlib.metadata instead.","severity":"deprecated","affected_versions":">=30.1.0"},{"fix":"Use semver (30.x.y) for current versions; ignore CalVer references.","message":"Pre-v30.0.0 used CalVer versioning; current versions are semantic (30.x.y). Some older documentation may reference CalVer patterns.","severity":"gotcha","affected_versions":">=30.0.0"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Use: from typecode import TypeCode. Ensure typecode >= 30.0.0 is installed.","cause":"Using wrong import path (e.g., from typecode.type import TypeCode) or stale installation.","error":"ImportError: cannot import name 'TypeCode' from 'typecode'"},{"fix":"Install libmagic (e.g., sudo apt install libmagic1 on Debian/Ubuntu, brew install libmagic on macOS) or install the system_provided extra: pip install typecode[system_provided].","cause":"libmagic shared library not found on the system.","error":"OSError: cannot load library 'magic'"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}