Download
Platforms
PythonMusic runs on Windows, Mac, and Linux.
Download and Install
To install PythonMusic, simply download the PEM (Python Environment for Music) editor.
PEM is bundled with all PythonMusic libraries, and other essential Python libraries. It should be enough for most uses.
NOTE: For more advanced users, see install PythonMusic via pip.
Windows
- Download PEM for Windows.
- Double-click PEM.exe to run.
- (Optional) Right-click PEM.exe, and select "Create Shortcut". Move this shortcut to your Desktop for easy access.
Mac
- Download PEM for MacOS.
- Move PEM to your Applications folder.
- Double-click PEM to run.
- (Optional) While PEM is running, control-click the PEM icon on the taskbar. Select “Options” and “Keep in Dock” for easy access.
Mac Security Issue
Some versions of MacOS flag the PEM application as damaged (or malware). This is a common issue caused by Apple's strict security protocols, and does not mean the application is unsafe. If so:
- Select “Cancel” (not "Move to Trash"!).
- Open System Settings.
- In “Privacy & Security”, scroll down to see a Security alert for PEM.
- Select “Allow”, and open PEM again.
Alternatively - after you move PEM to the Applications folder:
- Open a Terminal window.
- Type this command:
sudo xattr -dr com.apple.quarantine /Applications/PEM.app/
Linux (and Intel Mac)
The PEM executable is not available for Linux and Intel-based Macs.
To install PythonMusic see install via pip.
Download the Examples
PythonMusic comes with online examples. You can also download them.
Install via pip (Advanced)
For more advanced users, install PythonMusic via pip. This provides access to the full Python ecosystem of libraries:
- Make sure you have Python3 installed (version 3.12 or greater).
- Open Terminal, and type:
pip install PythonMusic
PEM
Once PythonMusic is installed with pip, you can access PEM via the command line:
python -m pem
pem
You can also open a file with PEM:
python -m pem <filename.py>
or
pem <filename.py>
Troubleshooting
"CMake configuration failed"
Some of PythonMusic's dependencies may need to compile C++ code during installation.
-
On Windows, download and install Visual Studio Build Tools 2022. In the Visual Studio installer, make sure "Desktop Development with C++" is checked.
-
On MacOS, you can download and install XCode from the App Store.
Restart your computer, then try installing PythonMusic again.
Using PythonMusic
PythonMusic's core modules are the music, gui, timer, osc, and midi libraries. You can import these libraries into your python code using:
import music
from music import *
from music import Note, Play, C4, HN
Or a similar statement. PythonMusic includes a number of useful constants, so we recommend using wildcard imports like from music import *.
NOTE: The first time you import music, PythonMusic will ask to download a high-quality soundfont (FluidR3 G2-2.sf2) for you. This is necessary to play high quality MIDI sounds, and only needs to happen once.
Running PythonMusic Programs
There are several ways to run PythonMusic programs:
-
Use provided PEM editor (for beginners – easiest)
-
Use Sublime editor (for intermediate users)
-
Use VS Code editor (for intermediate users)
-
Use Atom editor (for intermediate users)
-
Use Atom editor (for advanced users – very customizable)
-
Use terminal window (for advanced users – pure freedom!!!)
NOTE: Most advanced editors allow customization – by exploring the above instructions, you should be able to make your preferred editor run PythonMusic, as long as it provides a way to specify which run-time environment to use, when running files.
PythonMusic is designed for use in Python's Interactive Mode. To run a python program in interactive mode, use a command like:
python -i <filename.py>