I am trying to import NLTK library in Google App Engine it gives error, I created another module "testx.py" and this module works without error but I dont know why NLTK does not work.
My code nltk_test.py
import webapp2
import path_changer
import testx
import nltk
class MainPage(webapp2.RequestHandler):
def get(self):
#self.response.headers['Content-Type'] = 'text/plain'
self.response.write("TEST")
class nltkTestPage(webapp2.RequestHandler):
def get(self):
text = nltk.word_tokenize("And now for something completely different")
self.response.write(testx.test("Hellooooo"))
application = webapp2.WSGIApplication([
('/', MainPage), ('/nltk', nltkTestPage),
], debug=True)
testx.py code
def test(txt):
return len(txt)
path_changer.py code
import os import sys sys.path.insert(0, os.path.join(os.path.dirname(__file__), 'nltk')) sys.path.insert(1, os.path.join(os.path.dirname(__file__), 'new'))
app.yaml
application: nltkforappengine version: 0-1 runtime: python27 api_version: 1 threadsafe: true handlers: - url: /.* script: nltk_test.application - url: /nltk.* script: nltk_test.application libraries: - name: numpy version: "1.6.1"
This code works fine When I comment the import nltk and nltk related code, I think NLTK is not imported, please help me to sort out this problem, thanks