3

First of all, the python code is perfectly working in PyCharm and in command prompt. So, Cv2 module is installed well on my Windows machine.

But when I run by IronPython Script engine, it failed as below.

IronPython.Runtime.Exceptions.ImportException: No module named cv2

I setup IronPython engine as below. Note that site-packages has cv2.pyd file.

var engine = Python.CreateEngine();
List<string> pathes = engine.GetSearchPaths().ToList();
pathes.AddRange(new[]
{
    @"C:\Python27\Lib\", @"C:\Python27\Lib\site-packages\"
});
engine.SetSearchPaths(pathes);

dynamic py = engine.ExecuteFile("sample.py"); // <- Exception occurred here.

I guess engine.Setup.FileExtensions has only .py file, so that cv2.pyd is not recognized. But, I hardly figure out how to add .pyd to the setup.

Or, is there anything that I missed?

Youngjae
  • 24,352
  • 18
  • 113
  • 198

1 Answers1

1

I think you did nothing wrong, but *.pyd files are just not working for IronPython by default. Just checkout IronClad or this so article: https://stackoverflow.com/a/1231131/2630261

Community
  • 1
  • 1
BendEg
  • 20,098
  • 17
  • 57
  • 131