Registry / communication / python-rtmidi

python-rtmidi

JSON →
library1.5.8pypypi✓ verified 86d ago

Python bindings for the RtMidi C++ library, providing real-time MIDI input/output using Cython. Current version 1.5.8, updates irregularly.

pip install python-rtmidi
INSTALL
IMPORT
SIG · PYTHON-RTMIDI
P
python-rtmidi
communicationpythonv1.5.8
Install
1.6s avg
Import
Disk
18MB
Pass rate
4/ 10
Env Coverage4 / 10
glibc
3.93.13
musl
3.93.13
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
musl
glibc
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.')
Debug
Known issues
breakingIn version 1.5.8, Linux wheels no longer bundle libasound. If ALSA is not installed, the module will fail to load.
fix
Install ALSA development libraries (e.g., libasound2-dev on Debian) or use system package manager.
affects: >=1.5.8
gotchaMidiIn and MidiOut objects are not thread-safe. Do not call methods from multiple threads without external locking.
fix
Use threading.Lock or restrict calls to a single thread.
affects: all
gotchaOn macOS, the library defaults to CoreMIDI but can be built with JACK. Ensure you have the correct backend installed.
fix
Check your installation with `import rtmidi; print(rtmidi.get_api())`.
affects: all
deprecatedThe `midiutils` module is deprecated and may be removed in a future version.
fix
Use `get_ports()` methods on MidiIn/MidiOut instead.
affects: >=1.5.0
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.
fix
Install 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.
fix
Run `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.
fix
Use `from rtmidi import MidiIn`.
ValueError: Port index out of range
Port index exceeds number of available ports.
fix
Check 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.

Agent activity
26 hits · last 30 days
node
22
OpenAI (training)
1
Resources
python-rtmidi — pip install python-rtmidi · libregistry