2013-03-21 113 views
5

在64位操作系统的窗口中,一旦我为我的64位python安装了nltk-2.0.4.win-amd64-py2.7.exe,从http://www.lfd.uci.edu/~gohlke/pythonlibs/,我运行'import nltk'以获得以下错误!为什么我不能导入nltk?

Traceback (most recent call last): 
    File "<pyshell#25>", line 1, in <module> 
    import nltk 
    File "C:\Python27\lib\site-packages\nltk\__init__.py", line 131, in <module> 
    from inference import * 
    File "C:\Python27\lib\site-packages\nltk\inference\__init__.py", line 19, in <module> 
    from discourse import (ReadingCommand, CfgReadingCommand, 
    File "C:\Python27\lib\site-packages\nltk\inference\discourse.py", line 54, in <module> 
    from nltk.sem.glue import DrtGlue 
    File "C:\Python27\lib\site-packages\nltk\sem\glue.py", line 13, in <module> 
    from nltk.corpus import brown 
    File "C:\Python27\lib\site-packages\nltk\corpus\__init__.py", line 70, in <module> 
    from reader import * 
    File "C:\Python27\lib\site-packages\nltk\corpus\reader\__init__.py", line 85, in <module> 
    from nltk.corpus.reader.pl196x import * 
    File "C:\Python27\lib\site-packages\nltk\corpus\reader\pl196x.py", line 11, in <module> 
    from nltk import tokenize, tree 
ImportError: cannot import name tokenize 

有关如何解决此问题的建议将不胜感激。谢谢

+0

您是否尝试从源代码安装它,如[在此解释](http://nltk.org/install.html#source-installation-for-32-bit-or-64-bit-windows)? – Bakuriu 2013-03-21 08:42:43

+0

你肯定使用Python 2.7? 您是否也安装了PyYaml(以及可选的numpy)?我刚刚在[nltk网站](http://nltk.org/install.html)上按照说明操作,我在导入nltk模块(32位Windows上的python 2.7.3)时没有任何问题,但我无法看到64位与您遇到的错误有丝毫差异)。 – 2013-03-21 11:49:30

+0

这非常奇怪,它并没有发生在我身上的Linux中。我认为发生这种情况的主要原因之一是因为我安装了两个蟒蛇,32位和64位,他们一起冲突,所有的模块都搞乱了,我试图去掉其中一个,但徒劳无功,因为他们因为某种原因停留在注册表中。谢谢 – Curious 2013-03-21 17:36:07

回答

0

我通过创建一个环境变量“PYTHONPATH”我的Python安装路径的值解决了这个。