スクリプトファイルとしてエラーを取得10.11.4 私はPythonシェルで直接次のコードを実行していますし、それは完全にnltk.tokenizeシェルから適切に実行するが、私はマックOSでのpythonアイドル3.5.1を使用
>>> import nltk
>>> from nltk.tokenize import sent_tokenize, word_tokenize
>>> sample_sentence = "Hi, this is a sample sentence. Python is great"
>>> sample_sentence
'Hi, this is a sample sentence. Python is great'
>>> sent_tokenize(sample_sentence)
['Hi, this is a sample sentence.', 'Python is great']
>>>
の作品
私はスクリプトファイルと同じコードを保存しています。実行するとエラーが発生します。 エラーが発生しています。私は次のエラーに
RESTART: /Users/Documents/sample_codes/python3_sample.py Traceback (most recent call last): File "/Users/Documents/sample_codes/python3_sample.py", line 2, in from nltk.tokenize import sent_tokenize, word_tokenize ImportError: No module named 'nltk.tokenize'; 'nltk' is not a package
を取得しています。このスクリプトファイルを実行すると
import nltk
from nltk.tokenize import sent_tokenize, word_tokenize
sample_sentence = "Hi, this is a sample sentence. Python is great"
print(sent_tokenize(sample_sentence))
私はこれを理解していません。助けてください
ありがとうございます。
同じ問題はhttp://stackoverflow.com/questions/1663762/tokenizer-errors-with-nltk – alvas
これらも同じです:http://stackoverflow.com/questions/24592238/nltk-no-module-named-corpus私の場合、ファイル名はnltk.pyではなく、python3_sample.pyであるのが – alvas