[英]Python -- How to rename Musescore path in package music21?
I tried to install the Python package music21 and am having a problem running it in Windows.我尝试安装 Python 包 music21,但在 Windows 中运行时遇到问题。 Basically, when I tried to run the simple command they give as an example
基本上,当我尝试运行他们举的简单命令时
converter.parse("tinynotation: 3/4 c4 d8 f g16 a g f#").show()
I got an error我有一个错误
SubConverterException: Cannot find a path to the 'mscore' file at C:\Program Files (x86)\MuseScore 2\MuseScore.exe -- download MuseScore
The reason for this is because Musescore.exe is no longer stored in the folder "MuseScore 2" but now in a subfolder called "bin".这样做的原因是因为 Musescore.exe 不再存储在文件夹“MuseScore 2”中,而是现在存储在名为“bin”的子文件夹中。 So the path needs to be set to be "C:\\Program Files (x86)\\MuseScore 2\\bin\\MuseScore.exe" in order to access Musescore.
因此需要将路径设置为“C:\\Program Files (x86)\\MuseScore 2\\bin\\MuseScore.exe”才能访问 Musescore。
How do I change this?我该如何改变?
Full Error完全错误
SubConverterException Traceback (most recent call last)
<ipython-input-8-46c66c71749d> in <module>()
----> 1 converter.parse("tinynotation: 3/4 c4 d8 f g16 a g f#").show()
C:\Users\MrNoName\Anaconda3\lib\site-packages\music21\stream\__init__.py in show(self, *args, **kwargs)
255 if self.isSorted is False and self.autoSort:
256 self.sort()
--> 257 return super(Stream, self).show(*args, **kwargs)
258
259 #---------------------------------------------------------------------------
C:\Users\MrNoName\Anaconda3\lib\site-packages\music21\base.py in show(self, fmt, app, **keywords)
2586 app=app,
2587 subformats=subformats,
-> 2588 **keywords)
2589
2590 #--------------------------------------------------------------------------
C:\Users\MrNoName\Anaconda3\lib\site-packages\music21\converter\subConverters.py in show(self, obj, fmt, app, subformats, **keywords)
312
313 if 'Opus' not in obj.classes:
--> 314 fp = helperSubConverter.write(obj, helperFormat, subformats=helperSubformats)
315
316 defaults.title = savedDefaultTitle
C:\Users\MrNoName\Anaconda3\lib\site-packages\music21\converter\subConverters.py in write(self, obj, fmt, fp, subformats, **keywords)
808
809 if subformats is not None and 'png' in subformats:
--> 810 fp = self.runThroughMusescore(fp, **keywords)
811 return fp
812
C:\Users\MrNoName\Anaconda3\lib\site-packages\music21\converter\subConverters.py in runThroughMusescore(self, fp, **keywords)
756 raise SubConverterException(
757 "Cannot find a path to the 'mscore' file at " +
--> 758 "%s -- download MuseScore" % musescorePath)
759
760 fpOut = fp[0:len(fp) - 3]
SubConverterException: Cannot find a path to the 'mscore' file at C:\Program Files (x86)\MuseScore 2\MuseScore.exe -- download MuseScore
导入 music21 后立即执行此操作:
environment.set('musescoreDirectPNGPath', 'C:\\Program Files (x86)\\MuseScore 2\\bin\\MuseScore.exe')
For MuseScore 3对于 MuseScore 3
us = environment.UserSettings()
us['musicxmlPath'] = 'C:\\Program Files\\MuseScore 3\\bin\\MuseScore3.exe'
us['musescoreDirectPNGPath'] = 'C:\\Program Files\\MuseScore 3\\bin\\MuseScore3.exe'
us['musicxmlPath']
And if it still does not work, try opening the environment.py with sublime or else in C:\\Users\\YOU\\AppData\\Local\\Programs\\Python\\Python39\\Lib\\site-packages\\music21\\environment.py
then change '%PROGRAMFILES%\\MuseScore 3\\MuseScore.exe'
for '%PROGRAMFILES%\\MuseScore 3\\bin\\MuseScore.exe'
如果它仍然不起作用,请尝试在
C:\\Users\\YOU\\AppData\\Local\\Programs\\Python\\Python39\\Lib\\site-packages\\music21\\environment.py
使用 sublime 或其他方式打开C:\\Users\\YOU\\AppData\\Local\\Programs\\Python\\Python39\\Lib\\site-packages\\music21\\environment.py
然后更改'%PROGRAMFILES%\\MuseScore 3\\MuseScore.exe'
for '%PROGRAMFILES%\\MuseScore 3\\bin\\MuseScore.exe'
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.