Replies: 1 comment 1 reply
|
ctypes.WinDLL(r"C:\Program Files\QGIS 3.28.2\apps\qgis\python\qgis_core.pyd") Is this possible in PythonNET? |
1 reply
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.
Environment
Details
Describe what you were trying to get done.
I was trying to use some QGIS functions (64 bit).
What commands did you run to trigger this issue? If you can provide a
Minimal, Complete, and Verifiable example
this will help us understand the issue.
Here is my code. You will need to download and install QGIS3.8.2.
import os
import ctypes
p = r'C:\PROGRA
1\QGIS321.2\apps\qgis\bin;C:\PROGRA1\QGIS321.2\apps\grass\grass78\lib;C:\PROGRA1\QGIS321.2\apps\grass\grass78\bin;C:\PROGRA1\QGIS321.2\apps\qt5\bin;C:\PROGRA1\QGIS321.2\apps\Python39;C:\PROGRA1\QGIS321.2\bin'#;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\system32\WBem'lst=p.split(';')
lst.append(r'C:\WINDOWS')
lst.append(r'C:\WINDOWS\sysWOW64')
for f in lst:
os.add_dll_directory(f)
os.environ["PATH"]=';'.join(lst)
ctypes.WinDLL(r"C:\Program Files\QGIS 3.28.2\apps\qgis\python\qgis_core.pyd")
An error was thrown at ctypes.WinDLL():
[WinError 193] %1 is not a valid Win32 application
File "C:\Program Files\QGIS 3.28.2\apps\Python39\Lib\ctypes_init_.py", line 374, in init
The same code runs OK in Python3.9 64 bit. I wonder if Python runtime was trying to load a 32 bit DLL while a 64 bit DLL with the same file name exists. If that's the case, is there an option to prioritize the 64 bit DLL?
All reactions