I am using python.net to import a python module in C#. Everything worked well until recently when I experienced dramatic slow down on module import. Nothing changed on the machine other then Windows updates and McAfee updates. I am suspecting Windows Defender or McAfee to block the python.net bridge but any clue or previous experience to solve this issue is welcome. I am working locally so its not a shared drive issue.
Here is a reproducible example in c#:
PythonEngine.Initialize();
using (Py.GIL())
{
PythonScope = Py.CreateScope();
PythonScope.Exec("import numpy as np"); //this line recently takes forever (> 15 sec !!!)
}
So here I show numpy package import as example. The interesting thing is that if I time the import of this package in Git Batch before and after the C# call, you can also see the dramatic difference:
Then if I wait a bit, and try the import in Git Batch again, it comes back to normal. So there is something very odd going on with python.net. Any advice/clue on what is causing this would be welcome.
McAfee Adaptive Threat Protection is blocking python.net calls. You need to disable it in order to work with python.net.