Brew Python

Posted on  by admin
Latest version


File type identification using libmagic

Project description

Graph-tool is an efficient Python module for manipulation and statistical analysis of graphs (a.k.a. Contrary to most other Python modules with similar functionality, the core data structures and algorithms are implemented in C, making extensive use of template metaprogramming, based heavily on the Boost Graph Library. The Missing Package Manager for macOS (or Linux). It’s all Git and Ruby underneath, so hack away with the knowledge that you can easily revert your modifications and merge upstream updates.

python-magic is a Python interface to the libmagic file typeidentification library. libmagic identifies file types by checkingtheir headers according to a predefined list of file types. Thisfunctionality is exposed to the command line by the Unix commandfile.


There is also a Magic class that provides more direct control,including overriding the magic database file and turning on characterencoding detection. This is not recommended for general use. Inparticular, it's not safe for sharing across multiple threads andwill fail throw if this is attempted.

You can also combine the flag options:


The current stable version of python-magic is available on PyPI andcan be installed by running pip install python-magic.

Other sources:

  • PyPI:
  • GitHub:

This module is a simple wrapper around the libmagic C library, andthat must be installed as well:



You'll need DLLs for libmagic. @julian-r maintains a pypi package with the DLLs, you can fetch it with:


  • When using Homebrew: brew install libmagic
  • When using macports: port install file


  • 'MagicException: could not find any magic files!': someinstallations of libmagic do not correctly point to their magicdatabase file. Try specifying the path to the file explicitly in theconstructor: magic.Magic(magic_file='path_to_magic_file').

  • 'WindowsError: [Error 193] %1 is not a valid Win32 application':Attempting to run the 32-bit libmagic DLL in a 64-bit build ofpython will fail with this error. Here are 64-bit builds of libmagic for windows: version can be found here:

  • 'WindowsError: exception: access violation writing 0x00000000 ' This may indicate you are mixingWindows Python and Cygwin Python. Make sure your libmagic and python builds are consistent.

Bug Reports

Brew Install Pip

python-magic is a thin layer over the libmagic C library.Historically, most bugs that have been reported against python-magicare actually bugs in libmagic; libmagic bugs can be reported on theirtracker here: If you're notsure where the bug lies feel free to file an issue on GitHub and I cantriage it.

Running the tests

To run the tests across a variety of linux distributions (depends on Docker):

To run tests locally across all available python versions:

To run against a specific python version:

libmagic and python-magic

See for a guide to libmagic / python-magic compatability.


Minor version bumps should be backwards compatible. Major bumps are not.


Written by Adam Hupp in 2001 for a project that never got off theground. It originally used SWIG for the C library bindings, butswitched to ctypes once that was part of the python standard library.

You can contact me via my website orGitHub.


python-magic is distributed under the MIT license. See the includedLICENSE file for details.

I am providing code in the repository to you under an open source license. Because this is my personal repository, the license you receive to my code is from me and not my employer (Facebook).

Release historyRelease notifications RSS feed



0.4.20 yanked

0.4.19 yanked













Brew Upgrade Python









Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for python-magic, version 0.4.22
Filename, sizeFile typePython versionUpload dateHashes
Filename, size python_magic-0.4.22-py2.py3-none-any.whl (12.6 kB) File type Wheel Python version py2.py3 Upload dateHashes
Filename, size python-magic-0.4.22.tar.gz (17.0 kB) File type Source Python version None Upload dateHashes

Hashes for python_magic-0.4.22-py2.py3-none-any.whl

Brew Python 3.8

Hashes for python_magic-0.4.22-py2.py3-none-any.whl
AlgorithmHash digest

Hashes for python-magic-0.4.22.tar.gz

Hashes for python-magic-0.4.22.tar.gz
AlgorithmHash digest

Brew Python 3.7

  • Install Homebrew

    Paste that in a macOS Terminal or Linux shell prompt.

    The script explains what it will do and then pauses before it does it. Read about other installation options.

  • What Does Homebrew Do?

    Homebrew installs the stuff you need that Apple (or your Linux system) didn’t.

  • Homebrew installs packages to their own directory and then symlinks their files into /usr/local.

  • Homebrew won’t install files outside its prefix and you can place a Homebrew installation wherever you like.

  • It’s all Git and Ruby underneath, so hack away with the knowledge that you can easily revert your modifications and merge upstream updates.

  • Homebrew complements macOS (or your Linux system). Install your RubyGems with gem and their dependencies with brew.

  • “To install, drag this icon…” no more. Homebrew Cask installs macOS apps, fonts and plugins and other non-open source software.

  • Donate to Homebrew

  • Homebrew Blog

  • Analytics Data

  • Homebrew was created by Max Howell. Website by Rémi Prévost, Mike McQuaid and Danielle Lalonde.