What is the cause of "DLL load failed while importing cv2" using the pythondll under the same folder of the csproj? #2157
Unanswered
IChKEInDEUTSCH
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Python version: 3.10.6
Dotnet Version: 7.0.203
opencv-python Version: 4.7.0
Pythonnet Version: 3.0.1
In this csproject, I have python310.dll undder the same folder of my cs program. Below is th e c# code
If I set the path of SetEnvironmentVariable "PYTHONNET_PYDLL" as @"python310.dll",
will result the following error
Unhandled exception. Python.Runtime.PythonException: DLL load failed while importing cv2: The specified module could not be found. File "C:\Users\xcxx\AppData\Local\Programs\Python\Python310\Lib\importlib\__init__.py", line 126, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "C:\Users\xxcx\AppData\Local\Programs\Python\Python310\lib\site-packages\cv2\__init__.py", line 153, in bootstrap native_module = importlib.import_module("cv2") File "C:\Users\xxcx\AppData\Local\Programs\Python\Python310\lib\site-packages\cv2\__init__.py", line 181, in <module> bootstrap() at Python.Runtime.PythonException.ThrowLastAsClrException() at Python.Runtime.NewReferenceExtensions.BorrowOrThrow(NewReference& reference) at Python.Runtime.PyModule.Import(String name) at Python.Runtime.Py.Import(String name) at autofocus_csharp.canny_edge_counts.Main(String[] args) in D:\Alltempo\autofocus_csharp\canny_edge_counts.cs:line 27But if I set the absolute path of the python310.dll where my python is installed
then there will be no error.
By exaimning the Environment.GetEnvironmentVariables(), having the abs path, Environment.SetEnvironmentVariable will return less system variables then having @"python31.dll", which I don't know wether it matters.
The same error did appears when printing out the Environment.GetEnvironmentVariables() when the path is @"python310.dll"
Both scenario numpy is functioning normally, so is there a way use python310.dll instead?
I will commit or paste the code of the init.py if someone intreasted. Thanks in advance.
All reactions