0

I am using IronPython 3.4 in Visual Studio and I am trying to get nltk to work. I had an error saying no module named 'nltk' but I have got this to work now. Now I am getting the exception of no module named 'future' this is my code:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Policy;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp4
{
    class Program
    {
        static void Main(string[] args)
        {
            Microsoft.Scripting.Hosting.ScriptEngine pythonEngine = IronPython.Hosting.Python.CreateEngine();
            ICollection<string> paths = pythonEngine.GetSearchPaths();
            string dir = "C:\\Users\\Charlie\\Anaconda3\\Lib\\site-packages";
            paths.Add(dir);
            pythonEngine.SetSearchPaths(paths);
            Microsoft.Scripting.Hosting.ScriptSource pythonScript = pythonEngine.CreateScriptSourceFromString("import nltk");
            pythonScript.Execute();

        }
    }
}

I am getting this error:

IronPython.Runtime.Exceptions.ImportException: 'No module named '__future__''

When I go to anaconda prompt however and type pip install future I am getting this returned:

Requirement already satisfied (use --upgrade to upgrade): future in c:\users\charlie\anaconda3\lib\site-packages

Any ideas would be greatly appreciated. Thank you!

  • Does this answer your question? [How to install packages/modules in IronPython](https://stackoverflow.com/questions/39595327/how-to-install-packages-modules-in-ironpython) – Tyler Aldrich Nov 03 '22 at 13:33
  • @TylerAldrich, unfortunately not. I have IronPython installed as a NuGet package – charliewhittaker Nov 03 '22 at 13:36
  • The `__future__` module is a CPython module that provides backwards compatibility, so if Anaconda uses it and IronPython doesn't also have it's own `__future__` module, I don't think it'd be possible to use anaconda here. – Tyler Aldrich Nov 03 '22 at 13:47

0 Answers0