1

我想使用这个名为 Music21 的框架。

在外壳中一切正常。例如,命令:

from music21 import corpus

完美运行。在 IDE 中存在导入错误。

music21 路径是:

>>> music21.__file__
'/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/music21/__init__.pyc'

我把这条路径放在IDE中: 在此处输入图像描述

编辑:命令:

导入 music21 打印目录(music21)

在外壳中给我:

['DefinedContexts','DefinedContextsException','ElementException','ElementWrapper','GroupException','Groups','JSONSerializer','JSONSerializerException','Music21Exception','Music21Object','Music21ObjectException','Test',' TestMock'、'VERSION'、'VERSION_STR'、'WEAKREF_ACTIVE'、' all '、 'builtins' 、' doc '、' file '、' name '、' package '、' path', 'abc', 'abj', 'analysis', 'articulations', 'bar', 'base', 'beam', 'chord', 'chordTables', 'clef', 'codecs', 'common', 'composition','configure','converter','copy','corpus','counterpoint','defaults','demos','derivation','doc','doctest','duration','dynamics ', '编辑', 'environLocal', '环境', '表达式', 'figuredBass', 'graph', 'humdrum', 'inspect', 'instrument', 'interval', 'intervalNetwork', 'json', '键','布局','百合','mainTest','matplotlib','medren','元数据','meter','midi','musedata','musicxml','note','numpy','parse','pitch','ratio','repeat','roman','romanText','scale ', 'serial', 'sieve', 'spanner', 'stream', 'sys', 'tempo', 'test', 'text', 'tie', 'tinyNotation', 'trecento', 'types', 'unittest'、'uuid'、'voiceLeading'、'xmlnode']'test'、'text'、'tie'、'tinyNotation'、'trecento'、'types'、'unittest'、'uuid'、'voiceLeading'、'xmlnode']'test'、'text'、'tie'、'tinyNotation'、'trecento'、'types'、'unittest'、'uuid'、'voiceLeading'、'xmlnode']

在 IDE 中:

['作者','内置','日期',' doc ','文件','名称','','music21']

4

3 回答 3

1

In Python, every directory than contains __init__.py is a package. And the sys.path contains the directories in which Python searches for the packages, so you should use

'/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/'

to be able to import music and other packages from that directory.

于 2011-06-14T22:25:59.263 回答
1

路径应该是正确的 python 可执行文件或其文件夹。

于 2011-06-14T22:07:56.517 回答
0

看起来您已将 music21 安装在一个也称为 music21 的文件夹中,而后者(外部)文件夹位于您的 IDE 路径中,但在其他情况下,内部文件夹位于您的路径中。因此,当您在 IDE 中键入“import music21”时,您已经导入了外部文件夹,您需要键入这个晦涩的命令“from music21 import music21”才能访问实际的工具包。

--

如果“语料库”是您看到的唯一问题,我猜您安装了两个不同版本的 music21,其中一个是工具包的“noCorpus”版本,来自:http ://code.google.com/ p/music21/下载/列表

我们制作 noCorpus 版本的唯一原因是其中的一些文件不是全球范围内的自由软件(它们都完全在美国获得许可)和 Linux Dist。想用它打包music21,但不能包含一些语料库文件。除非您的磁盘空间非常低或维护墨西哥的生命版权法+100 等,否则您可能不需要 noCorpus 版本。

于 2012-06-27T05:40:17.673 回答