在Python的IDLE中导入audiolazy的问题

hvvq6cgz  于 11个月前  发布在  Python
关注(0)|答案(1)|浏览(1315)

我正在尝试打开4个在Python 3.12中运行的包:pandas,matplotlib,audiolazy和midiutil。
我在IDLE中运行以下脚本:

import sys
import subprocess
for package in ['pandas','matplotlib', 'audiolazy', 'midiutil']:
     subprocess.check_call([sys.executable, '-m', 'pip', 'install', package])

字符串
我用下面的脚本导入pandas,matplotlib和midiutil没有问题:

import pandas as pd  
import matplotlib.pylab as plt  
from midiutil import MIDIFile


但是当我运行:from audiolazy import str2midiimport audiolazy来验证它是否正确安装时,我遇到了以下错误:
from audiolazy import str2midi Traceback(最近的电话):文件“<pyshell#9>",第1行,in from audiolazy import str 2 midi文件“/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/audiolazy/init.py”,第67行,in).init_package(pathnamedoc)File“/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/audiolazy/_internals.py”,line 117,in init_package modules = get_modules(package_name,module_names)File“/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/audiolazy/_internals.py”,line 59,in get_modules return [get_module(name)for name in module_names] File“/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/audiolazy/_internals.py”,第58行,在get_module returnimport中(“.".join([package_name,name]),fromlist=[package_name])File“/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/audiolazy/lazy_analysis.py”,line 23,in from collections import deque,Sequence,Iterable ImportError:无法从“collections”导入名称“Sequence "(/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/collections/init.py)
导入音频跟踪(最近的电话):文件“<pyshell#5>",第1行,在import audiolazy文件“/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/audiolazy/init.py”,第67行,在).init_package(pathnamedoc)File“/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/audiolazy/_internals.py”,line 117,in init_package modules = get_modules(package_name,module_names)File“/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/audiolazy/_internals.py”,line 59,in get_modules return [get_module(name)for name in module_names] File“/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/audiolazy/_internals.py”,第58行,get_module返回import(“.".join([package_name,name]),fromlist=[package_name])File“/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/audiolazy/lazy_analysis.py”,line 23,in from collections import deque,Sequence,Iterable ImportError:无法从“collections”导入名称“Sequence "(/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/collections/init.py)
我试着用这个脚本from collections import Sequence从集合中导入Sequence(之前已经导入了集合),但我仍然遇到类似的问题:
Traceback(most recent call last):File“<pyshell#8>",line 1,in from collections import Sequence ImportError:cannot import name 'Sequence' from 'collections'(/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/collections/init.py)
我真的很感激你提供的任何帮助,以便能够在Python的IDLE中成功导入audiolazy。

dnph8jn4

dnph8jn41#

此导入错误与IDLE无关。您直接使用Python运行代码时会得到相同的错误。以下是3.13.0a2的IDLE shell:

>>> from collections.abc import Sequence
>>> Sequence
<class 'collections.abc.Sequence'>

字符串
你可能需要升级(编辑)audiolazy代码来做同样的事情。

相关问题