"Couldn't open /etc/timidity/freepats.cfg"-an error occurred when running python.musicpy library on Ubuntu system

"Couldn't open /etc/timidity/freepats.cfg"-an error occurred when running python.musicpy library on Ubuntu system

Project scene

The musicpy library is a library written by our people that allows you to write beautiful music with a concise grammar and music theory logic. Through this library, you can use simple computer grammar to express a piece of music. Isn’t it cool?


Problem Description

When using the musicpy library, there is no problem with the import of the library and the creation of musical notation classes.

>>> from musicpy.musicpy import *
pygame 2.0.0 (SDL 2.0.12, python 3.8.5)
Hello from the pygame community. https://www.pygame.org/contribute.html
>>> a = note('A', 1)
>>> b = chord('A')
>>> 

But when outputting the result, the following error appeared:

>>> play(b)
Traceback (most recent call last):
  File "sound_test.py", line 17, in <module>
    mixer.music.load("********")
pygame.error: Couldn't open /etc/timidity/freepats.cfg

The specific error is as follows:

pygame.error: Couldn’t open /etc/timidity/freepats.cfg


Cause Analysis

Unable to open may be due to lack of freepats.cfg file


solution

Simple and straightforward, open the terminal and install freepats to fix it

sudo apt-get install freepats

Attached (musicpy learning video)

The installation of the musicpy library is very simple, just pip:

pip3 install musicpy

Finally, attach the first phase of the introduction and use tutorial video made by the author of musicpy:

https://www.bilibili.com/video/BV1754y197a9/

For detailed musicpy data structure, basic grammar and usage tutorial, please see WiKi that the author is writing:

https://github.com/Rainbow-Dreamer/musicpy/wiki


If you are helpful, please like it, thank you for your support~

Guess you like

Origin blog.csdn.net/weixin_46584887/article/details/110814354