I'm trying to execute a simple Python script from C# program. The Python script imports cv2 and numpy. This script works when executing from command line, but cannot find cv2 when executing from C#. I'm using Anaconda3, IronPython, Windows 10, Visual Studio 2015 Profesional. I'm new to Python, but I think this may be a path/location problem.
The instruction:
engine.ExecuteFile(@"C:\Development\Test.py");
gives the following exception:
"No module named cv2"
See the code below:
Using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using IronPython.Hosting;
using Microsoft.Scripting.Hosting;
namespace EmbededPyConsoleTest
{
class Program
{
static void Main(string[] args)
{
ExecutePythonScript();
}
private static void ExecutePythonScript()
{
ScriptEngine engine = Python.CreateEngine();
engine.ExecuteFile(@"C:\Development\Test.py");
}
}
}
Python test script:
import cv2
import numpy as np
-
-
-
-