我可以像这样在python shell中导入ntlk和pos_tag。
>>> import nltk
>>> from nltk import pos_tag
但是当我需要编写一个脚本时
import nltk
from nltk import pos_tag
我收到回溯错误
Traceback (most recent call last):
File "mynltkfile.py", line 1, in <module>
from nltk import pos_tag
File "/Users/jacksongeller/Desktop/nltktest/mynltkfile.py", line 1, in <module>
from nltk import pos_tag
ImportError: cannot import name pos_tag
我已经完成了 nltk.download() 并下载了所有内容。我也用管道传输了 numpy
此外,如果我只是从脚本中导入 nltk,我会得到相同的回溯
Traceback (most recent call last):
File "mynltkfile.py", line 1, in <module>
import nltk
File "/Users/jacksongeller/Desktop/nltktest/mynltkfile.py", line 1, in <module>
from nltk import pos_tag
ImportError: cannot import name pos_tag
我错过了一个文件吗?如果是这样,它应该去哪里?提前致谢