【发布时间】:2014-10-02 05:33:28
【问题描述】:
也许我在这里完全遗漏了一些东西,但是当我从 shell 运行这段代码时,它可以工作:
import nltk
tokens = nltk.word_tokenize("foo bar")
然后返回:
['foo','bar']
但是当我把它放到一个文件中并用 python -u "path/to/file/myfile.py" 执行它时,它会返回
AttributeError: 'module' object has no attribute 'word_tokenize'
我已经尝试过重新安装以及我能想到的一切。如果您需要更多信息,请告诉我。
提前致谢!
【问题讨论】:
-
你的 python 脚本文件名是什么?
标签: python shell module python-module