I am trying to load my DLL (32bit) file containing CPP functions into python. It works on python 3.7 (32bit) but it gives an error when using canopy 3.5 (32bit).
the code I use to load my dll:
import os
import ctypes
os.chdir(r"G:\DLLdirectory")
mydll = ctypes.cdll.LoadLibrary('MyDLL.dll')
If I run it on pyton 3.7 it works, if I run it with canopy 3.5 I get:
Traceback (most recent call last):
File "DIR/PythonFile.py", line 26, in <module>
mydll = ctypes.cdll.LoadLibrary('MyDLL.dll')
File "DIR\Canopy32\edm\envs\User\lib\ctypes\__init__.py", line 425, in LoadLibrary
return self._dlltype(name)
File "DIR\Canopy32\edm\envs\User\lib\ctypes\__init__.py", line 347, in __init__
self._handle = _dlopen(self._name, mode)
OSError: [WinError 126] The specified module could not be found
If you change os.chdir() to sys.path.append() in canopy still the module is not found and in python 3.7 I get this error:
Traceback (most recent call last):
File "DIR/PythonFile.py", line 26, in <module>
mydll = ctypes.cdll.LoadLibrary('MyDLL.dll')
File "DIR\Python\Python37-32\lib\ctypes\__init__.py", line 434, in LoadLibrary
return self._dlltype(name)
File "DIR\Python37-32\lib\ctypes\__init__.py", line 356, in __init__
self._handle = _dlopen(self._name, mode)
OSError: [WinError 193] %1 is not a valid Win32 application