No module named nltk

48 views
Skip to first unread message

J Saiteja

unread,
Jan 4, 2018, 9:29:02 AM1/4/18
to nltk-users
Hello im sai teja reddy
Problem : getting the error Message - No module named nltk while i was calling the python script with web service
Explanation :
I have a python script which returns data and calling this python script by creating a webservice i.e., i have integrated python and c# using ironpython and now the problem is i am successfully able to run the python code using command prompt and getting the correct output but when i'm calling through asmx it is throwing an error as below :

Message - No module named nltk Stack trace- at Microsoft.Scripting.Runtime.LightExceptions.CheckAndThrow(Object value) at Microsoft.Scripting.Interpreter.FuncCallInstruction`2.Run(InterpretedFrame frame) at Microsoft.Scripting.Interpreter.Interpreter.Run(InterpretedFrame frame) at Microsoft.Scripting.Interpreter.LightLambda.Run2[T0,T1,TRet](T0 arg0, T1 arg1) at IronPython.Compiler.PythonScriptCode.RunWorker(CodeContext ctx) at Microsoft.Scripting.Hosting.ScriptSource.Execute(ScriptScope scope) at CallAsmxViajQuery.AbbieCassService.SuggestedUtterances(String inputString)

My trails :
after googling a lot i got solutions like adding the sys.path. So after giving the correct path like 

import sys
sys.path.append(r'C:\Python\lib\site-packages')  #here is where my nltk module exists
sys.path.append(r'C:\Python\lib\site-packages\nltk')
sys.path.append(r'C:\Python\lib\site-packages\nltk\__init__.py')

it gave a new error like:

Message - No module named __future__ Stack trace- at Microsoft.Scripting.Runtime.LightExceptions.CheckAndThrow(Object value).......

so i have imported __future__ and gave the below mentioned code to my python script : 

sys.path.append(r'C:\Python\lib')     #here is where my __future__ module exists
sys.path.append(r'C:\Python\lib\__future__.py')  

Now i'm getting an issue like 
Message - unexpected token 'from' Stack trace- at IronPython.Runtime.ThrowingErrorSink.Add................

Request : Can anyone exactly tell me how to import nltk using ironpython.Any help is accepted


Dimitriadis, A. (Alexis)

unread,
Jan 4, 2018, 4:33:31 PM1/4/18
to nltk-...@googlegroups.com
__future__ is not a normal module; do not “create” it. Language features can be “imported” from it, but the imports must be at the very start of a module. You don’t show the stack trace that raised this error, but it sounds like you pasted your path-appending code above a __future__ import. Move it lower to fix the problem.

Alexis


--
You received this message because you are subscribed to the Google Groups "nltk-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nltk-users+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages