Using PythonNET to call some scripts written in Python from a C# developing environment. I am using a virtual environment. I am running into this error:
System.DllNotFoundException: 'Unable to load DLL 'python35': The specified module could not be found. (Exception from HRESULT: 0x8007007E)'
I read at the documentation telling me I need to set my PATH, PYTHONPATH, and PYTHONHOME variables to my virtual environment.
I am still not 100% if my virtual environment has been set up properly. I am using WSL Ubuntu v18 and using the command virtualenv env
creates me the necessary folder structure; however, the bin folder is populated with files that are 0-1KB. I have virtualenv on PowerShell and when using that, a different folder structure is created but its bin directory is the actual Python files. If someone knows about this, please comment!
I have tried setting my path variables as so:
string virtualEnvPath = Environment.CurrentDirectory + @"\env";
string pythonPath = virtualEnvPath + @"\lib\python3.7;" + virtualEnvPath + @"\lib\python3.7\site-packages";
Environment.SetEnvironmentVariable("PATH", virtualEnvPath, EnvironmentVariableTarget.Process);
Environment.SetEnvironmentVariable("PYTHONHOME", virtualEnvPath, EnvironmentVariableTarget.Process);
Environment.SetEnvironmentVariable("PYTHONPATH", pythonPath, EnvironmentVariableTarget.Process);
I have also added Python.Runtime.dll
to my references and still no avail.
I just need my C# application to load in the correct directories. Thanks for reading!
EDIT: This is the documentation I was referring to - PythonNET with VirtualEnv
User contributions licensed under CC BY-SA 3.0