title: Integrating Python script in .NET C#
body: <p>I am trying at my current application to integrate a pretty complex Python script in .NET platform using IronPython as a bridge.</p>
  
  <p>In my python script I use NLTK and also some other string classifiers like <code>sklearn.naive_bayes</code>, this are my import's:</p>
  
  <pre><code>import nltk
  
  from nltk.classify.scikitlearn import SklearnClassifier
  import pickle
  
  from sklearn.naive_bayes import MultinomialNB, BernoulliNB
  
  from sklearn.linear_model import LogisticRegression, SGDClassifier
  </code></pre>
  
  <p>Also I have in this script a function that receive as a parameter a string and return some output example:</p>
  
  <pre><code>def testFunction(text):
      #do some things
      return somethings
  </code></pre>
  
  <p>I want to call this function from my .NET application, I am using this code for calling the function:</p>
  
  <pre><code>        ScriptEngine engine;
          ScriptScope scope;
          ScriptSource source;
          CompiledCode compiled;
  
          engine = Python.CreateEngine();
          scope = engine.CreateScope();
  
          ICollection&lt;string&gt; paths = engine.GetSearchPaths();
          string dir = @"C:\Users\Desktop\WinPython-64bit-3.4.3.6\python-3.4.3.amd64\Lib";
          paths.Add(dir);
          string dir2 = @"C:\Users\Desktop\WinPython-64bit-3.4.3.6\python-3.4.3.amd64\Lib\site-packages";
          paths.Add(dir2);
  
          engine.SetSearchPaths(paths);
  
          //loading and compiling code
          source = engine.CreateScriptSourceFromFile(@"C:\Users\Desktop\script.py");
  
  
          compiled = source.Compile();
  
          //now executing this code (the code should contain a class)
          compiled.Execute(scope);
  </code></pre>
  
  <p>When I try to execute the code I get the following eror:</p>
  
  <pre><code>SyntaxErrorException -&gt; unexpected token 'from'.
  </code></pre>
  
  <p>I want to call the <code>testFunction</code> with a string and then use the output if that function in .NET.</p>