Install & Compatibility
Where this runs
tested against v1.5.8 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
py 3.10
✕ build_error
✓ 1.6s
py 3.11
✕ build_error
✓ 1.6s
py 3.12
✕ build_error
✓ 1.5s
py 3.13
✕ build_error
✕ build_error
py 3.9
✕ build_error
✓ 1.85s
18MB installed
● package 18MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
MidiIn
✓ from rtmidi import MidiIn
✗ from rtmidi.midi import MidiIn
Old import path from version <1.0
MidiOut
✓ from rtmidi import MidiOut
✗ from rtmidi.midi import MidiOut
Old import path from version <1.0
Basic setup: list ports, open input, set callback.
from rtmidi import MidiIn, MidiOut
# List available ports
midi_in = MidiIn()
print('Input ports:', midi_in.get_ports())
midi_out = MidiOut()
print('Output ports:', midi_out.get_ports())
# Open first port and listen
if midi_in.get_ports():
midi_in.open_port(0)
# Callback example
def callback(message, data):
print(message)
midi_in.set_callback(callback)
import time
time.sleep(2)
midi_in.close_port()
else:
print('No MIDI input ports found.')
Errors
Common errors & fixes
ImportError: libasound.so.2: cannot open shared object file: No such file or directory
Linux wheel does not bundle ALSA libraries starting version 1.5.8.
fixInstall ALSA development libraries: `sudo apt-get install libasound2-dev` on Debian/Ubuntu.
ModuleNotFoundError: No module named 'rtmidi'
Package not installed or virtual environment not activated.
fixRun `pip install python-rtmidi` and ensure you are in the correct environment.
ImportError: cannot import name 'MidiIn' from 'rtmidi.midi'
Using old import path from version <1.0.
fixUse `from rtmidi import MidiIn`.
ValueError: Port index out of range
Port index exceeds number of available ports.
fixCheck number of ports with `midi_in.get_ports()` before opening.
Upgrade
Version history
1.5.8latest on PyPI · released Nov 20, 2023
Audit
Dependencies
No dependency data recorded yet.