谷歌应用引擎导入NLTK错误



我试图在谷歌应用程序引擎中导入NLTK库,它给出了错误,我创建了另一个模块"testx.py",这个模块工作无错误,但我不知道为什么NLTK不工作。

我的代码nltk_test.py

<>之前进口webapp2进口path_changer进口testx进口nltk类主页(webapp2.RequestHandler):def(自我):# self.response。headers['Content-Type'] = 'text/plain'self.response.write("测试")类nltkTestPage (webapp2.RequestHandler):def(自我):文本= nltk。word_tokenize("现在是完全不同的东西")self.response.write (testx.test("嘿"))应用= webapp2。WSGIApplication ([('/', MainPage), ('/nltk', nltkTestPage),】,debug = True)之前

testx.py代码<>之前def测试(txt):返回len (txt)之前

path_changer.py代码<>之前进口操作系统导入系统sys.path。插入(0,os.path.join (os.path.dirname (__file__), nltk))sys.path。插入(os.path.join (os.path.dirname (__file__), '新'))之前

app.yaml

<>之前应用范围:nltkforappengine版本:0 - 1运行时:python27api_version: 1线程安全的:真正的处理程序:—url:/.*脚本:nltk_test.application—url:/nltk.*脚本:nltk_test.application库:—name: numpy版本:"1.6.1"之前

这段代码运行正常当我注释导入nltk和nltk相关代码时,我认为nltk没有导入,请帮我整理一下这个问题,谢谢

nltk安装在哪里?

GAE库需要在你的app文件夹中可用。如果你在pythonpath的其他地方有nltk,它将无法工作。