0

I have written the following code and I am getting no module named fcntl when i am running the python script using C#

print "hi how are you"
import nltk
a="hi how are you"
tokens=nltk.word_tokenize(a)
print tokens
oxfn
  • 6,590
  • 2
  • 26
  • 34
  • [fcntl](http://docs.python.org/2/library/fcntl.html) is only available on unix. Are you developing on Windows? If so, how did you get `fcntl`? Maybe try to re-install using their instructions [here](http://www.nltk.org/install.html#windows) – mgilson Mar 12 '14 at 05:31

1 Answers1

0

Possibly NLTK depends on subprocess module, which is not supported in embedded IronPython. There're already some answers on the subject:

sys.path

Also check your sys.path. Probably it is not set automatically for embedded engine. You can set library paths like this:

engine.SetSearchPaths(
    new string[]
    {
        "C:\\Program Files\\IronPython 2.7",
        "C:\\Program Files\\IronPython 2.7\\Lib",
        "C:\\Program Files\\IronPython 2.7\\Lib\\site-packages",
    }
);

sys.platform

Any module, dependent on fcntl, decides to import it only if sys.platform == 'posix'. Debug it's actual value inside your python code and try to force it to "win32" (before any other imports)

import sys
sys.platform = "win32"
Community
  • 1
  • 1
oxfn
  • 6,590
  • 2
  • 26
  • 34