Installation

python-rtmidi uses the de-facto standard Python distutils and setuptools based packaging system and can be installed from the Python Package Index via pip. Since it is a Python C(++)-extension, a C++ compiler and build environment as well as some system-dependent libraries are needed to install, unless wheel packages with precompiled binaries are available for your system. See the Requirements section below for details.

From PyPI

If you have all the requirements, you should be able to install the package with pip:

$ pip install python-rtmidi

This will download the source distribution from python-rtmidi’s PyPI page, compile the extension and install it in your active Python installation. Unless you want to change the Cython source file _rtmidi.pyx, there is no need to have Cython installed.

python-rtmidi also works well with virtualenv and virtualenvwrapper. If you have both installed, creating an isolated environment for testing and/or using python-rtmidi is as easy as:

$ mkvirtualenv rtmidi
(rtmidi)$ pip install python-rtmidi

Pre-compiled Binaries

Binary wheels with a pre-compiled version for Windows with Windows MultiMedia API support are available through PyPI for several Python versions. If you install python-rtmidi via pip (see above), these wheels should be picked up by it automatically, if you have compatible Python and Windows versions.

From the Source Distribution

Of course, you can also download the source distribution package as a Zip archive or tarball, extract it and install using the common distutils commands, e.g.:

$ pip download python-rtmidi
$ unzip python-rtmidi-1.1.0.zip
$ cd python-rtmidi-1.1.0
$ python setup.py install

From the Source Code Repository

Lastly, you can check out the python-rtmidi source code from the Git repository and then install it from your working copy. Since the repository does not include the C++ module source code pre-compiled from the Cython source, you’ll also need to install Cython >= 0.17, either via pip or from its Git repository. Using virtualenv/virtualenvwrapper is strongly recommended in this scenario:

Make a virtual environment:

$ mkvirtualenv rtmidi
(rtmidi)$ cdvirtualenv

Install Cython from PyPI:

(rtmidi)$ pip install Cython

or the Git repository:

(rtmidi)$ git clone https://github.com/cython/cython.git
(rtmidi)$ cd cython
(rtmidi)$ python setup.py install
(rtmidi)$ cd ..

Install python-rtmidi:

(rtmidi)$ git clone https://github.com/SpotlightKid/python-rtmidi.git
(rtmidi)$ cd python-rtmidi
(rtmidi)$ python setup.py install

Requirements

Naturally, you’ll need a C++ compiler and a build environment. See the platform-specific hints below.

If you want to change the Cython source file _rtmidi.pyx or want to recompile _rtmidi.cpp with a newer Cython version, you’ll need to install Cython >= 0.17. The _rtmidi.cpp file in the current source distribution (version 1.1.0) is tagged with:

/* Generated by Cython 0.25.2 */

RtMidi (and therefore python-rtmidi) supports several low-level MIDI frameworks on different operating systems. Only one of the available options needs to be present on the target system, but support for more than one can be compiled in. The setup script will try to detect available libraries and should use the appropriate compilations flags automatically.

  • Linux: ALSA, JACK
  • OS X: CoreMIDI, JACK
  • Windows: MultiMedia (MM)

Linux

First you need a C++ compiler and the pthread library. Install the build-essential package on debian-based systems to get these.

Then you’ll need Python development headers and libraries. On debian-based systems, install the python-dev package. If you use the official installers from python.org you should already have these.

To get ALSA support, you must install development files for the libasound library (debian package: libasound-dev). For JACK support, install the libjack development files (libjack-dev or libjack-jackd2-dev).

OS X

Install the latest Xcode version or g++ from MacPorts or homebrew (untested). CoreMIDI support comes with installing Xcode. For JACK support, install JACK for OS X with the full installer.

Note

If you have a version of OS X and Xcode which still supports building binaries for PPC, you’ll have to tell distribute to build the package only for i386 and x86_64 architectures:

env ARCHFLAGS="-arch i386 -arch x86_64" python setup.py install

Windows

Please see the detailed instructions for Windows in How to install python-rtmidi from source on Windows.

User Contributed Documentation

The python-rtmidi wiki on GitHub contains some user contributed documentation for additional installation scenarios. Please check these, if you have trouble installing python-rtmidi in an uncommon or not-yet-covered environment.