I am trying to call a python class from my c# file in Unity3d. Numpy and os modules work fine.
void Start()
{
startTime = Time.time;
using (Py.GIL())
{
dynamic np = Py.Import("numpy");
UnityEngine.Debug.Log(np.cos(np.pi * 2));
dynamic sin = np.sin;
UnityEngine.Debug.Log(sin(5));
double c = np.cos(5) + sin(5);
UnityEngine.Debug.Log(c);
dynamic a = np.array(new List<float> { 1, 2, 3 });
UnityEngine.Debug.Log(a.dtype);
dynamic b = np.array(new List<float> { 6, 5, 4 }, dtype: np.int32);
UnityEngine.Debug.Log(b.dtype);
UnityEngine.Debug.Log(a * b);
dynamic os = Py.Import("os");
UnityEngine.Debug.Log(os.getcwd());
dynamic test = Py.Import("clrTest"); // this throws me an error
}
}
clrTest is my custom class clrTest.py
class clsMyTest:
"""clsTest.clsMyTest class"""
@staticmethod
def Test03():
return 42
def Test04():
return 42
def Test01():
return 42
@staticmethod
def Test02():
return 42
I get this following error
PythonException: ModuleNotFoundError : No module named 'clrTest'
Python.Runtime.Runtime.CheckExceptionOccurred () (at <38fa310f96774b388b3fb5f7d3ed5afc>:0)
Python.Runtime.PythonEngine.ImportModule (System.String name) (at <38fa310f96774b388b3fb5f7d3ed5afc>:0)
Python.Runtime.Py.Import (System.String name) (at <38fa310f96774b388b3fb5f7d3ed5afc>:0)
I tried placing my python file in same directory as the c# file, in the root directory and in the Plugins foler. Still I get this error. What to do?