0

I am using music21 with MuseScore in an ipython notebook. It works well, the only problem is that every time I create a Stream and then run my_stream.show(), it takes a forever because it waits to open the MuseScore application. This happens even if MuseScore is already open (it opens a second copy of the app, which then closes itself after the image is printed).

How can I prevent music21 from re-opening MuseScore each time and get it to use the already opened app instead?

EDIT: Adding version/OS info

I'm on a mac (OSX 10.10.4) using MuseScore version 2.1.0

I've also tried the method outlined here to print out sheet music in an ipython notebook but the same thing happened.

For the second method at least, the problem seems to be in music21/converter/subConverter.py.

Under

class ConverterMusicXML(SubConverter):

There's this section:

    musescoreRun = '"' + musescorePath + '" ' + fp + " -o " + fpOut + " -T 0 "
    if 'dpi' in keywords:
        musescoreRun += " -r " + str(keywords['dpi'])

    if common.runningUnderIPython():
        musescoreRun += " -r " + str(defaults.ipythonImageDpi)

    storedStrErr = sys.stderr
    fileLikeOpen = six.StringIO()
    sys.stderr = fileLikeOpen
    os.system(musescoreRun)
    fileLikeOpen.close()
    sys.stderr = storedStrErr

I believe that this line in particular

os.system(musescoreRun)

is opening MuseScore independently each time, but I can't figure out what to replace it with that will allow music21 to find the already running instance of MuseScore.

Jeff
  • 11
  • 1
  • 2
  • It may have something to do with your OS. On Mac it works fine and last time I checked, on PC worked great too. More info about OS etc. would need to be there – Michael Scott Asato Cuthbert Jul 10 '17 at 14:02
  • Ok I added a lot more info about the versions/OS and where I suspect the problem is. And thanks for music21 by the way Michael! It's been really helpful. – Jeff Jul 11 '17 at 15:52

1 Answers1

0

Same problem errors. Here refers an issue on GitHub:

... changing os.system(musescoreRun) line 891 of subconverters.py by subprocess.run(musescoreRun). You need also to import subprocess at the start of subconverters.py.

Maybe it works for you!