首页 > 解决方案 > Python edifact 库无法在 Windows 10 上运行

问题描述

您好,在此先感谢您,

Python 是一种我不经常使用的语言,但我对我在 github 上找到的一个名为pydifact的 edifact 库很感兴趣。我运行该示例,它在 linux 上运行良好,但在 windows 10 上出现错误...我使用了 python 3.10

Traceback (most recent call last):
File "C:\Python\testApp.py", line 1, in <module>
from pydifact.segmentcollection import Interchange
File "c:\users\myname\pydifact\pydifact\__init__.py", line 23, in <module>
from pydifact import segmentcollection, parser, segments, serializer, token, 
tokenizer
File "c:\users\myname\pydifact\pydifact\segmentcollection.py", line 339, in <module>
class Interchange(FileSourcableMixin, UNAHandlingMixin, AbstractSegmentsContainer):
File "c:\users\myname\pydifact\pydifact\segmentcollection.py", line 425, in Interchange
cls, segments: Union[list, collections.Iterable]
AttributeError: module 'collections' has no attribute 'Iterable'

有什么想法吗?

标签: pythonedifact

解决方案


线

cls, segments: Union[list, collections.Iterable]

错误消息提到的,表明它Iterable不在collections模块中。自 3.3 版起colections.<smth>,Python 被弃用。collections.abc.<smth>从 3.10 开始,这种不推荐使用的行为被完全删除并引发错误。

因此,您应该降级到 python 3.9 或更早版本或替换所有出现的

collections.Iterable

collections.abc.Iterable

推荐阅读