Version 1 (modified by admin, 7 years ago) (diff)


How to install python-rtmidi from source on Windows

These instruction are only working for installing python-rtmidi from source using Python 2.7 or Python 3.3 in the 32-bit versions (you can run these on Windows 64-bit versions with no problems).

Please follow all the steps below in the exact order.

Installing required software

You probably need adminstrator rights for some or all of the following steps.

  1. Install Python 2.7.x or Python 3.3 (32-bit!) from to the default location (i.e. C:\Python27 or C:\Python33).

  2. (Optional: add C:\Python27 and C:\Python27\Scripts resp. C:\Python33 and C:\Python33\Scripts to your PATH.)

  3. Install setuptools (the following commands assume that you are using Python 2.7. If you are using Python 3.3, use C:\Python33 in place of C:Python27 in the commands given).

    • Download

    • Open a command line and run it:

      > C:\Python27\python
  4. Install pip:

    > C:\Python27\Scripts\easy_install pip
  5. Install virtualenv:

    > C:\Python27\Scripts\pip install virtualenv
  6. Install Visual Studio Express (Microsoft Visual C++).

    • For Python 2.7 (and 3.2) install Visual Studio Express 2008.
    • For Python 3.3 install Visual Studio Express 2010.

    You'll have to use an internet search to find a current download link for the installer or an ISO with the whole distribution.

    Please make sure that you install the correct Visual Studio Express edition for the Python version you are using as detailed above. You can install Visual Studio Express 2008 and 2010 at the same time.

    After installation, use Windows Update to get any pending security updates and fixes.

Setting up a virtual environment

  1. Open a command line and run:

    > C:\Python27\Scripts\virtualenv rtmidi
    > rtmidi\Scripts\activate
  2. Install Cython (still in the same command line window):

    > pip install Cython

Download & unpack python-rtmidi source

Get the latest python-rtmidi distribution as a Zip archive from, unpack it somewhere, and, in the command line window you opened above, change into python-rtmidi directory, which you unpacked, e.g.:

> pip install --no-install -d . "python-rtmidi>=0.4"
> cd python-rtmidi

If you use a non-english version of Windows XP (or possibly Vista), adapt the values of WINLIB_DIR and WININC_DIR at the top of file to your system to point to the location of WinMM.lib and the Microsoft SDK headers.

Build & install Python-rtmidi

Just run the usual setup command from within the source directory with the active virtual environment, i.e. from still the same command line window:

> python install

This might also download some version of setuptools in the process again. You can also update setuptools within your virtual environment beforhand to the latest version with:

> pip install -U setuptools

Verify your installation

Change out of the python-rtmidi source directory (important!) and run:

> cd ..
> python
>>> import rtmidi
>>> rtmidi.API_WINDOWS_MM in rtmidi.get_compiled_api()
>>> midiout = rtmidi.MidiOut()
>>> midiout.get_ports()
[u'Microsoft GS Wavetable Synth']

That's it, congratulations!


Compiling python-rtmidi with Windows Kernel Streaming support currently does not work due to syntax errors in RtMidi.cpp. This is currently being investigated. You can enable Windows Kernel Streaming Support by providing the --winks option to the invocation, but this curently only leads to a compiler error.

Compiling with MinGW also does not work out-of-the-box yet. If you have any useful hints, please let the author know.