I'm writing C++ code which should invoke python scripts underneath. For this purpose I use cpython of python.org. Some of the python scripts execute .net code with help of python for .net and when it comes to .net all this fails. I tried to build test app to verify where it fails and found that it can't import clr module.
When I run this code it give me ImportError: No module named clr
Py_Initialize();
PyRun_SimpleString("import clr");
If I go to python console and type "import clr" everything works fine. I also checked sys.path and it contains the folder where clr.pyd located 'C:\Python27\DLLs'. I also tried setting this path in C++ by:
char* path = "C:\\Python27\\dlls";
Py_Initialize();
PySys_SetArgv(1, &path);
char* phome = Py_GetPythonHome();
But it didn't helped. In addition I don't understand why clr module is appears as clr.pyd and not .pyc like other compiled modules.
Could someone can explain why import clr fails through CPython? Is it possible to make it work?
To install clr, you have to install pythonnet library.
You can install pythonnet using following command.
pip install pythonnet