import rtmidi_python as rtmidi
vmidi_out = rtmidi.MidiOut()
vmidi_out.open_virtual_port('My Virtual MIDI Output Port')
vmidi_out.send_message([144, 48, 100])
vmidi_out.send_message([176, 7, 100])
Configure Mac OS X MIDI programatically