1

My working code broke after upgrading to Python 3.8.1. Following line used to work, but now returns an error message:

cdll.LoadLibrary('mydllpath/mydll.dll')
==> Could not find module 'mydll.dll'. Try using the full path with constructor syntax.

Someone suggested adding the dll folder to the dll search path. So I changed the code to:

    os.chdir('mydllpath')
    print(os.listdir())  # Proof of success
    os.add_dll_directory('mydllpath')
    cdll.LoadLibrary('my.dll')
    # cdll.LoadLibrary('mydllpath/my.dll')  # Also unsuccessful

Well, the print() on second line of code lists mydll.dll as one of the files in the directory, but Python/cdll still returns the exact same error message: "Could not find ..."
Looking for ideas/suggestions. Thanks ...

1
  • Hard to tell what's wrong, but I'd guess that some dependencies are missing since the upgrade. You might have to recompile. If that doesn't work, extract and provide a minimal reproducible example and provide the full (!) error message including the backtrace. Commented Mar 3, 2020 at 14:16

1 Answer 1

2

OK, I figured-out the issue: Python returned error message: "Could not find module 'mydll.dll'" whether is had a problem locating mydll, or another dll that mydll depends upon. Python 3.8.2 also makes the error message a bit more descriptive.
In my case, mydll.dll depends on a widely used dll located one level-up the directory tree. Once I added that folder to my search path using os.add_dll_directory(), the program started working again.

Sign up to request clarification or add additional context in comments.

2 Comments

Did you have problems Python throwing you an AttributeError: module 'os' has no attribute 'add_dll_directory' ? This is what I get when I do os.add_dll_directory(dllpath) - dllpath of course being the main folder where all my driver dlls are
Sorry, that's a new one for me. Idea: Look into the module "os" to make sure the error message is correct.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.