在Python中导入nltk包时出现问题
我打字的时候在Python中导入nltk包时出现问题,python,python-2.7,syntax-error,nltk,python-import,Python,Python 2.7,Syntax Error,Nltk,Python Import,我打字的时候 import nltk 在Python解释器中,它给了我-- 有解决方案吗?您有一个名为new.py的本地文件。检查当前目录并重命名或删除它 您可以在回溯中看到这一点: File "/usr/lib/python2.7/dist-packages/scipy/stats/distributions.py", line 87, in <module> from new import instancemethod File "new.py", line 3
import nltk
在Python解释器中,它给了我--
有解决方案吗?您有一个名为new.py的本地文件。检查当前目录并重命名或删除它
您可以在回溯中看到这一点:
File "/usr/lib/python2.7/dist-packages/scipy/stats/distributions.py", line 87, in <module>
from new import instancemethod
File "new.py", line 3
文件“/usr/lib/python2.7/dist-packages/scipy/stats/distributions.py”,第87行,在
从新导入实例方法
文件“new.py”,第3行
前面的模块有一个完整的文件路径,但是new.py
文件没有,这使得它成为一个本地文件,在scipy.stats.distributions
@Martijn中隐藏相对导入。谢谢,上面的问题解决了。不幸的是,现在我遇到了以下错误-->>>导入nltk回溯(上次调用):文件“”,第1行,在文件“/usr/local/lib/python2.7/dist packages/nltk/_init_uuuuuuuuuu.py”中,第161行,在从下载器导入下载中,下载shell文件“/usr/local/lib/python2.7/dist packages/nltk/downloader.py”,第180行,在urlib2=nltk.internals.import_from_stdlib('urlib2')AttributeError:'module'对象没有属性'internals',您还有一个nltk.py
文件,也是本地文件。
"""Create new objects of various types.
Deprecated.This module is no longer required except for backward compatibility.
Objects of most types can now be created by calling the type object.
"""
from warnings import warnpy3k
warnpy3k("The 'new' module has been removed in Python 3.0; use the 'types' "
"module instead.", stacklevel=2)
del warnpy3k
from types import ClassType as classobj
from types import FunctionType as function
from types import InstanceType as instance
from types import MethodType as instancemethod
from types import ModuleType as module
from types import CodeType as code
File "/usr/lib/python2.7/dist-packages/scipy/stats/distributions.py", line 87, in <module>
from new import instancemethod
File "new.py", line 3