I'm using Visual Studio 2010. I have an IronPython console project and a C# console project. This IronPython script works fine when I run it by itself:
import nltk
def Simple():
baconIpsumFile = open('baconipsum.txt', 'r')
baconIpsumCorpus = baconIpsumFile.read()
tokens = nltk.word_tokenize(baconIpsumCorpus)
text = nltk.Text(tokens)
print text
Here is the C# console program, which does not work fine:
using IronPython.Hosting;
namespace IronNLTK.CSharp.Console
{
class Program
{
static void Main(string[] args)
{
var ipy = Python.CreateRuntime();
dynamic test = ipy.UseFile("C:\\Path\\To\\Program.py");
test.Simple();
}
}
}
I get an ImportException: No module named nltk
. What am I missing?
sounds like you need to update sys.path to point to wherever NLTK lives.
check this out: Importing external module in IronPython
Awesome news, Visual Studio 2017 is embedded with Anaconda’s Python distribution which has NTLK and other machine learning packages.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With