在我的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:\Users\Administrator\AppData\Local\Programs\Python\Python35-32\lib\site-packages\tethne-0.8-py3.5.egg\tethne\__init__.py", line 20, in <module>
from tethne.classes.paper import Paper
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python35-32\lib\site-packages\tethne-0.8-py3.5.egg\tethne\classes\paper.py", line 5, in <module>
from tethne.classes.feature import Feature, feature
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python35-32\lib\site-packages\tethne-0.8-py3.5.egg\tethne\classes\feature.py", line 20, in <module>
from itertools import chain, izip
ImportError: cannot import name 'izip'
我该如何解决这个问题?
感谢。
答案 0 :(得分:0)
您似乎正在使用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在izip
中没有itertools
,但内置zip
与Python2.x中的izip
执行相同的工作。