This brief tutorial module explains how to view notation in the music21 environment.
After you install music21, you must configure it for your system. As part of this process, you must install or specify a software program to display notation in the MusicXML format. The instructions for this configuration process are included as part of the installation instructions for different systems at the top of this page.
You can check whether you have everything set up properly by entering the following code line by line.
First, load the music21 environment:
from music21 import *
Next, load an example file from the music21 corpus:
example_chorale = corpus.parse('bach/bwv65.2.xml')
And use the .show() function to display the notation:
If music21 is configured properly on your system, the notation software you chose should automatically begin running, and the notation for J.S. Bach’s chorale “Ein Kind geborn zu Bethlehem” should appear after a moment.
In some cases, the software may present you with an “import” dialog box. Usually you can leave the default settings in place and simply click OK.
It may take a few seconds for the software and file to load. However, if the notation does not appear, return to the configuration process and specify your software of choice. Or consider downloading and installing Finale Notepad and MuseScore, and then run the configuration assistant again.
For more on MusicXML files and software, check this page.