在我的python项目中,我被添加:
from tethne.model.corpus import mallet
但我的问题是,当我运行我的项目时,我在 pycharm 控制台中看到这些错误:
Traceback (most recent call last):
File "D:/Python-Workspace(s)/BehnazDemo/Demo.py", line 1, in <module>
from tethne.model.corpus import mallet
File "C:UsersAdministratorAppDataLocalProgramsPythonPython35-32libsite-packagestethne-0.8-py3.5.eggtethne__init__.py", line 20, in <module>
from tethne.classes.paper import Paper
File "C:UsersAdministratorAppDataLocalProgramsPythonPython35-32libsite-packagestethne-0.8-py3.5.eggtethneclassespaper.py", line 5, in <module>
from tethne.classes.feature import Feature, feature
File "C:UsersAdministratorAppDataLocalProgramsPythonPython35-32libsite-packagestethne-0.8-py3.5.eggtethneclassesfeature.py", line 20, in <module>
from itertools import chain, izip
ImportError: cannot import name 'izip'
如何解决此问题?
谢谢。
看起来你使用的是Python3.x,所以代码应该是:
try:
from itertools import izip as zip
except ImportError: # Python3.x you can just use zip
pass
或:
from itertools import zip_longest
Python 3在itertools
中没有izip
,但内置zip
与Python2.x中的izip
相同。