不明白为什么我不能导入音乐21

时间:2019-12-15 23:00:30

标签: python python-3.x python-import music21

我是Python的新手,所以也许我可以先学习基础知识...我是音乐家,并且热衷于学习如何将Python与音乐结合使用。

我为Windows 10安装了Python 3.8 x64。然后我使用pip来安装音乐21。

打开Python Shell,输入import music21并得到:

    Python 3.8.0 (tags/v3.8.0:fa919fd, Oct 14 2019, 19:37:50) [MSC v.1916 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license()" for more information.
>>> import music21
Traceback (most recent call last):
  File "<pyshell#0>", line 1, in <module>
    import music21
  File "D:\Python\lib\site-packages\music21\__init__.py", line 170, in <module>
    from music21 import base
  File "D:\Python\lib\site-packages\music21\base.py", line 94, in <module>
    from music21 import common
  File "D:\Python\lib\site-packages\music21\common\__init__.py", line 39, in <module>
    from music21.common.parallel import *
  File "D:\Python\lib\site-packages\music21\common\parallel.py", line 19, in <module>
    from music21.ext.joblib import Parallel, delayed  # @UnresolvedImport # type: ignore
  File "D:\Python\lib\site-packages\music21\ext\joblib\__init__.py", line 119, in <module>
    from .parallel import Parallel
  File "D:\Python\lib\site-packages\music21\ext\joblib\parallel.py", line 32, in <module>
    from .externals.cloudpickle import dumps, loads
  File "D:\Python\lib\site-packages\music21\ext\joblib\externals\cloudpickle\__init__.py", line 3, in <module>
    from .cloudpickle import *
  File "D:\Python\lib\site-packages\music21\ext\joblib\externals\cloudpickle\cloudpickle.py", line 167, in <module>
    _cell_set_template_code = _make_cell_set_template_code()
  File "D:\Python\lib\site-packages\music21\ext\joblib\externals\cloudpickle\cloudpickle.py", line 148, in _make_cell_set_template_code
    return types.CodeType(
TypeError: an integer is required (got type bytes)

我找到了与music21一起运行的示例代码,但是如果遇到错误,我将无法使用它。

希望有人可以提供帮助。抱歉,如果我是一个完整的n00b。确实在看其他问题,但没有找到答案或不明白答案。

2 个答案:

答案 0 :(得分:0)

因此,从您的输出中,最有用的主要部件是TypeError: an integer is required (got type bytes)文件中_make_cell_set_template_code函数中的D:\Python\lib\site-packages\music21\ext\joblib\externals\cloudpickle\cloudpickle.py。此问题可能是music21与Python 3.8不兼容的问题。我正在阅读https://web.mit.edu/music21/上的文档,其中说v.5支持Python 3.4-3.6,因此我将尝试使用其中一个版本,然后重新开始执行上述步骤的过程。希望这会有所帮助!

答案 1 :(得分:0)

music21 v5不支持Python 3.8-选择3.7或从github下载最新的Git。

寻找你感兴趣的贴纸↓↓↓
豫ICP备18024241号-1