我在Mac OS 10.6.8上使用nltk时遇到问题。 我已经在nltk codumentation(http://nltk.org/install.html)中安装了Setuputools,Pip,Numpy,PyYAML和NLTK,但我试图在python中导入nltk时遇到此错误:
>>> import nltk
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/nltk/__init__.py", line 105, in <module>
from collocations import *
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/nltk/collocations.py", line 37, in <module>
from nltk.util import ingrams
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/nltk/util.py", line 12, in <module>
import pydoc
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/pydoc.py", line 55, in <module>
import sys, imp, os, re, types, inspect, __builtin__, pkgutil, warnings
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/inspect.py", line 39, in <module>
import tokenize
File "tokenize.py", line 13, in <module>
main(sys.argv[1])
IndexError: list index out of range
>>>
Python using
Python 2.7.6 (v2.7.6:3a1db0d2747e, Nov 10 2013, 00:42:54)
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>>
但是,如果我在pythons上做双重标签显示我确实安装了
pydoc python-config python2.6-config pythonw2-32
pydoc2 python2 python2.7 pythonw2.5
pydoc2.5 python2-32 python2.7-32 pythonw2.6
pydoc2.6 python2-config python2.7-config pythonw2.7
pydoc2.7 python2.5 pythonw pythonw2.7-32
python python2.5-config pythonw-32
python-32 python2.6 pythonw2
如果我再次尝试安装它会说它一切都很好,如果我尝试用pip install nltk
说明
Requirement already satisfied (use --upgrade to upgrade): nltk in /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages
Requirement already satisfied (use --upgrade to upgrade): PyYAML>=3.09 in /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages (from nltk)
Cleaning up...
我正在做一个我需要在这几天上交的学校项目,所以你的帮助真的,真的,真的是一个折旧! Thanx提前:))