I am calling a python script from C# code, which invoked a REST API to Authenticate and Upload a file into AMAZON S3.
public static string runPy()
{
{
debugLog(" ---- ---- Running Python ---- --- ");
debugLog(" Folder Directory : " + AppDomain.CurrentDomain.BaseDirectory);
String projectPath = Directory.GetParent(Environment.CurrentDirectory).Parent.Parent.FullName;
debugLog(" projectPath " + projectPath);
Microsoft.Scripting.Hosting.ScriptEngine py = Python.CreateEngine();
Microsoft.Scripting.Hosting.ScriptScope s = py.CreateScope();
// add paths to where your libs are installed
var libs = new[] { @"C:\ProgramData\Anaconda3\lib\site-packages\win32\lib", @"C:\ProgramData\Anaconda3\lib\site-packages\win32\lib" };
py.SetSearchPaths(libs);
py.Execute("print(\"Start of the PY program\")\r\nimport requests\r\nresponse = requests.get(\"http://api.open-notify.org/astros.json\")\r\nprint(response)");
debugLog("From Iron Python");
return "S";
}
}
Error I am getting is : Exception thrown: 'IronPython.Runtime.Exceptions.ImportException' in Microsoft.Dynamic.dll An unhandled exception of type 'IronPython.Runtime.Exceptions.ImportException' occurred in Microsoft.Dynamic.dll No module named 'requests'
Please I need quick help I did go through so many available threads but of no use.
python Code:
print("Start of the PY program")
import requests
response = requests.get("http://api.open-notify.org/astros.json")
print(response)