0

I wanna just use the C++ module. (or C), but when i try to import the .dll file, I always see the error.

I am just typing

test.ipynb

from ctypes import *
       mydll=windll.LoadLibrary "D:\\MyLab\\Python\\C++connect\\ddltest.dll")
  • My anaconda is 64bit.
  • Windows also is 64bit.

How can i solve this problem?

My full error message is this.


OSError Traceback (most recent call last) in ----> 1 mydll = windll.LoadLibrary("D:\MyLab\Python\C++connect\ddltest.dll")

D:\anaconda\envs\bigdata-platform\lib\ctypes__init__.py in LoadLibrary(self, name) 432 433 def LoadLibrary(self, name): --> 434 return self._dlltype(name) 435 436 cdll = LibraryLoader(CDLL)

D:\anaconda\envs\bigdata-platform\lib\ctypes__init__.py in init(self, name, mode, handle, use_errno, use_last_error) 354 355 if handle is None: --> 356 self._handle = _dlopen(self._name, mode) 357 else: 358 self._handle = handle

Roberto Caboni
  • 7,252
  • 10
  • 25
  • 39
Dhoon
  • 1
  • 2
  • https://stackoverflow.com/questions/57187566/python-ctypes-loading-dll-throws-oserror-winerror-193-1-is-not-a-valid-win/57297745#57297745 – CristiFati Dec 17 '19 at 10:42

1 Answers1

1

DLL's have to match the bit-ness of the executable, in this case the Python executable. Loading a 32 bits DLL in a 64 bit Python will fail as described, with a 193 error.

64 bit versions of Windows can still run 32 bits executables, because these Windows versions have two set of the system DLL's.

MSalters
  • 173,980
  • 10
  • 155
  • 350