Music21 的 运行 个模块中的 Julia PyCall 困难
Julia PyCall difficulties in running modules of Music21
我是初学者,在使用 Julia 的 PyCall 与 MIT Python 音乐模块 music21 交互时遇到困难。
根据 Music21 的网站,为了以乐谱形式显示短旋律,可以在 Python 中键入:
converter.parse("tinynotation: 3/4 c4 d8 f g16 a g f#").show()
以下是我尝试在 Julia 中执行这段代码的方法:
我首先初始化了 music21,这似乎有效:
@pyimport music21
music21: Certain music21 functions might need these optional packages: matplotlib, scipy; if you run into errors, install them by following the instructions at http://mit.edu/music21/doc/installing/installAdditional.html
然后我尝试通过键入以下内容在 Julia 中重新创建上述 Python 示例:
converter.parse("tinynotation: 3/4 c4 d8 f g16 a g f#").show()
I received this error:
ERROR: UndefVarError: converter not defined
Stacktrace:
[1] eval(::Module, ::Any) at ./boot.jl:235
更新 1
根据rickhg12hs的建议,我尝试了music21.converter.parse("tinynotation: 3/4 c4 d8 f g16 a g f#").show()。
现在我在 'Parse' 上收到此错误消息:错误:PyObject 类型没有字段解析 Stacktrace: eval(::Module, ::Any) at ./boot.jl:235
这似乎是一个改进,因为它现在在代码链中稍后崩溃,在 'Parse' 而不是 'Converter'。
更新 2 - 修复
此问题与 有关。
基于此 link,我尝试将我的代码修改为如下所示:
music21.converter[:parse]("tinynotation: 3/4 c4 d8 f g16 a g f#")[:show]()
但现在我得到这个错误
FSPathMakeRef(/Applications/MuseScore 2.app/Contents/MacOS/mscore) failed with error -43.
我发现我最后要做的就是下载 MuseScore,现在问题已经解决了!
请参阅@crstnbr 的回答,了解有关此解决方案的丑陋之处和即将进行的修复的更多背景信息。
非常感谢!
纳库尔
我没有安装这个包(我稍后会测试它)但是下面的应该可以工作:
@pyimport music21 as m
m.converter[:parse]("tinynotation: 3/4 c4 d8 f g16 a g f#")[:show]()
请注意,在我的 Pull request 此处合并后,Julia 1.0 中可以说丑陋的(但系统的)[:fieldname]
访问很快就会消失。使用这种语法的原因是 Julia 不允许覆盖 .
访问功能。幸运的是,这在 Julia 1.0 中有所改变。
我是初学者,在使用 Julia 的 PyCall 与 MIT Python 音乐模块 music21 交互时遇到困难。
根据 Music21 的网站,为了以乐谱形式显示短旋律,可以在 Python 中键入:
converter.parse("tinynotation: 3/4 c4 d8 f g16 a g f#").show()
以下是我尝试在 Julia 中执行这段代码的方法:
我首先初始化了 music21,这似乎有效:
@pyimport music21
music21: Certain music21 functions might need these optional packages: matplotlib, scipy; if you run into errors, install them by following the instructions at http://mit.edu/music21/doc/installing/installAdditional.html
然后我尝试通过键入以下内容在 Julia 中重新创建上述 Python 示例:
converter.parse("tinynotation: 3/4 c4 d8 f g16 a g f#").show()
I received this error:
ERROR: UndefVarError: converter not defined
Stacktrace:
[1] eval(::Module, ::Any) at ./boot.jl:235
更新 1 根据rickhg12hs的建议,我尝试了music21.converter.parse("tinynotation: 3/4 c4 d8 f g16 a g f#").show()。
现在我在 'Parse' 上收到此错误消息:错误:PyObject 类型没有字段解析 Stacktrace:
这似乎是一个改进,因为它现在在代码链中稍后崩溃,在 'Parse' 而不是 'Converter'。
更新 2 - 修复
此问题与
music21.converter[:parse]("tinynotation: 3/4 c4 d8 f g16 a g f#")[:show]()
但现在我得到这个错误
FSPathMakeRef(/Applications/MuseScore 2.app/Contents/MacOS/mscore) failed with error -43.
我发现我最后要做的就是下载 MuseScore,现在问题已经解决了!
请参阅@crstnbr 的回答,了解有关此解决方案的丑陋之处和即将进行的修复的更多背景信息。
非常感谢! 纳库尔
我没有安装这个包(我稍后会测试它)但是下面的应该可以工作:
@pyimport music21 as m
m.converter[:parse]("tinynotation: 3/4 c4 d8 f g16 a g f#")[:show]()
请注意,在我的 Pull request 此处合并后,Julia 1.0 中可以说丑陋的(但系统的)[:fieldname]
访问很快就会消失。使用这种语法的原因是 Julia 不允许覆盖 .
访问功能。幸运的是,这在 Julia 1.0 中有所改变。