Every time I got this was because my MIDI keyboard wasn't connected, check if your MIDI controller is being detected by some other software, also try midi.get_count() this should be more than 0.

Infrequently writes about things.