Python 2.x/3.x bindings for the Taglib audio metadata library
Python Shell
Latest commit 6e83677 May 16, 2017 @supermihi supermihi Update
Added a note regarding OS X issues

pytaglib – TagLib bindings for Python


pytaglib is a full-featured, easy-to-use, cross-platform audio metadata ("tag") library for Python (all versions supported). It uses the popular, fast and rock-solid TagLib C++ library internally; pytaglib is a very thin wrapper about TagLib (<150 lines of code), meaning that you immediately profit from the underlying library's speed and stability.

Features include support of more than a dozen file formats, arbitrary tag names, and multiple values per tag.

Known Issue: Various users have reported SIGSEGV errors on Mac OS X Sierra. Any help in debugging this is highly apprechiated (I do not have access to an OS X computer)!

Usage Example

  • Open a file and read its tags:
>>> import taglib
>>> song = taglib.File("/path/to/my/file.mp3")
>>> song.tags
{'ARTIST': ['piman', 'jzig'], 'ALBUM': ['Quod Libet Test Data'], 'TITLE': ['Silence'], 'GENRE': ['Silence'], 'TRACKNUMBER': ['02/10'], 'DATE': ['2004']}
  • Read some additional properties of the file:
>>> song.length
>>> song.channels
  • Change the file's tags:
>>> song.tags["ALBUM"] = ["White Album"] # always use lists, even for single values
>>> del song.tags["DATE"]
  • Multiple values per tag:
>>> song.tags["GENRE"] = ["Vocal", "Classical"]
  • Non-standard tags:
>>> song.tags["PERFORMER:HARPSICHORD"] = ["Ton Koopman"] 
  • Save your changes:
>>> returnvalue =
>>> returnvalue

The dictionary returned by save contains all tags that could not be saved (might happen if the specific format does not support e.g. multi-values).

Note: All strings in the tag dictionary are unicode strings (type str in Python 3 and unicode in Python 2). On the input side, however, the library is rather permissive and supports both byte- and unicode-strings. Internally, pytaglib converts all strings to UTF-8 before storing them in the files.


The most recommended installation method is

    pip install pytaglib

subject to the following notes:

  • Ensure that pip points to the correct Python version; you might need to use, e.g., pip-3.5 if you want to install pytaglib for Python 3.5 and your system's default is Python 2.7.

  • You may need administrator rights to install a package, i.e., sudo pip install pytaglib on Unix or running the command on a Admin console on windows

  • Alternatively, install locally into your user home with pip install --user pytaglib.

  • You need to have taglib installed with development headers (package libtag1-dev for debian-based linux, brew install taglib on OS X).

  • If taglib is installed at a non-standard location, you can tell pip where to look for its include (-I) and library (-L) files:

      pip install --global-option=build_ext --global-option="-I/usr/local/include/" --global-option="-L/usr/local/lib" pytaglib

If the above does not work, continue reading for alternative methods of installation.

Linux / Unix

Distribution-Specific Packages

  • Debian- and Ubuntu-based linux flavors have binary packages for the Python 3 version, called python3-taglib. Unfortunatelly, they are heavily outdated, so you should use the above "pip" method whenever possible.
  • For Arch users, there is a package in the user repository (AUR) which I try to keep up-to-date.

Manual Compilation

Alternatively, you can download / checkout the sources and compile manually:

    python build
    python test  # optional
    sudo python install

You can manually specify taglib's include and library directories:

python build --include-dirs /usr/local/include --library-dirs /usr/local/lib

Note: The taglib Python extension is built from the file taglib.cpp which in turn is auto-generated by Cython from taglib.pyx. To re-cythonize this file instead of using the shipped taglib.cpp, invoke with the --cython option.


Currently, the PyPI archive contains a binary version only for Python3.5/x64. For different combinations of Python version and architecture, you need to build yourself.

Note: The following procedure was tested for Python 3.5 on x64 only. Other python versions probably require some more work; see e.g. this page.

  1. Install Microsoft Visual Studio 2015 Community Edition. In the installation process, be sure to enable C/C++ support.
  2. Download and build taglib:
    1. Download the current taglib release and extract it somewhere on your computer.
    2. Start the VS2015 x64 Native Tools Command Prompt. On Windows 8/10, it might not appear in your start menu, but you can find it here: C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Visual Studio 2015\Visual Studio Tools\Windows Desktop Command Prompts
    3. Navigate to the extracted taglib folder and type: cmake -G "Visual Studio 14 2015 Win64" -DCMAKE_INSTALL_PREFIX=".\taglib-install" to generate the Visual Studio project files.
    4. Type msbuild INSTALL.vcxproj /p:Configuration=Release which will "install" taglib into the taglib-install subdirectory.
  3. Still in the VS2015 command prompt, navigate to the pytaglib directory.
  4. Tell pytaglib where to find taglib: set TAGLIB_HOME=C:\Path\To\taglib-install
  5. Build pytaglib: python build and install: python install


This package also installs the small script pyprinttags. It takes one or more files as command-line parameters and will display all known metadata of that files on the terminal. If unsupported tags (a.k.a. non-textual information) are found, they can optionally be removed from the file.


For bug reports or feature requests, please use the issue tracker on GitHub. For anything else, contact me by email.