pythonpermissionserrno

Errno 13 Musescore 3 outputting score png through python


I've been bashing my head against a wall for 2 days. Trying to get a png output of a music score. I was doing it successfully using show("lily") until I came across bars with only rests (no notes) where it'd refuse to output a png.

I'm now trying to show("musicxml.png") but run into a permission error. I've run chmod 777 and sudo chown root:wheel . /Applications/MuseScore\ 3.app, but the no joy! Any insight would be great.

(running MacOS)

from music21 import *


us = environment.UserSettings()

us['musicxmlPath'] = '/Applications/MuseScore 3.app'
us['musescoreDirectPNGPath'] = '/Applications/MuseScore 3.app'
s = stream.Stream()
s.append(note.Rest())
s.show("musicxml.png")

traceback (most recent call last):

File "/Users/brien/Documents/FinalProject/personal_learning/check_music21.py", line 10, in

s.show("musicxml.png")

File "/Users/brien/Documents/FinalProject/.venv/lib/python3.9/site-packages/music21/stream/base.py", line 334, in show return super().show(fmt=fmt, app=app, **keywords)

File "/Users/brien/Documents/FinalProject/.venv/lib/python3.9/site-packages/music21/base.py", line 2788, in show return formatWriter.show(self,

File "/Users/brien/Documents/FinalProject/.venv/lib/python3.9/site-packages/music21/converter/subConverters.py", line 1108, in show returnedFilePath = self.write(obj, fmt, subformats=subformats, **keywords)

File "/Users/brien/Documents/FinalProject/.venv/lib/python3.9/site-packages/music21/converter/subConverters.py", line 1091, in write outFp = self.runThroughMusescore(xmlFp, subformats, **keywords)

File "/Users/brien/Documents/FinalProject/.venv/lib/python3.9/site-packages/music21/converter/subConverters.py", line 964, in runThroughMusescore completed_process = subprocess.run(musescoreRun, capture_output=True, check=False)

File "/Users/brien/micromamba/lib/python3.9/subprocess.py", line 505, in run with Popen(*popenargs, **kwargs) as process:

File "/Users/brien/micromamba/lib/python3.9/subprocess.py", line 951, in init self._execute_child(args, executable, preexec_fn, close_fds,

File "/Users/brien/micromamba/lib/python3.9/subprocess.py", line 1821, in _execute_child raise child_exception_type(errno_num, err_msg, err_filename)

PermissionError: [Errno 13] Permission denied: '/Applications/MuseScore 3.app'

ls -l . /Applications

drwxrwxrwx@ 3 root wheel 96 8 Feb 2021 MuseScore 3.app


Solution

  • I had the same issue as you. The problem is that your path /Applications/MuseScore 3.app is fact a folder.

    music21 environment is waiting for an executable, so your path should be: /Applications/MuseScore 3.app/Contents/MacOS/mscore.

    Use Finder and right-click on your application name then Show Package Contents.

    This worked in my case. I hope this helps you.