ctypes.CDLL fails with error “[WinError 126] The specified module could not be found”

The issue is that we getting the following error:

[WinError 126] The specified module could not be found

When we are calling:

import ctypes

The following lines does working correctly:

import ctypes


  • Python version 3.7.2, 32bits
  • ctypes module version 1.1.0
  • The folder “C:\dio” was added to the windows ENV variables under Path.

Howdy Boaz,

just some hints:

  1. you can use raw strings by r"…" - then you do not need to use double backslashes.
  2. if I do remember that right, you also can use / slashes in path strings - even under Windows
  3. you can check, whether your path-string is correct, by using os.path.exists(…)

Cheers, Dominik