This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author eryksun
Recipients eryksun, jmoguill2, paul.moore, steve.dower, tim.golden, zach.ware
Date 2021-02-09.04:29:25
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1612844965.67.0.138996977709.issue43173@roundup.psfhosted.org>
In-reply-to
Content
> What's the correct way to set the DLL search path when running a python script?

If possible, the simplest approach is to put dependent DLLs in the same directory as the extension module. 

In 3.8+, the search path for the dependent DLLs of a normally imported extension module includes the following directories:

    * the loaded extension module's directory
    * the application directory (e.g. that of python.exe)
    * the user DLL search directories that get added by 
      SetDllDirectory() and AddDllDirectory(), such as with 
      os.add_dll_directory()
    * %SystemRoot%\System32

Note that the above list does not include the current working directory or %PATH% directories.

> It would be helpful if it listed the actual name of 
> the DLL that it cannot find.

WinAPI LoadLibraryExW() doesn't have an out parameter to get the missing DLL or procedure name that caused the call to fail. All we have is the error code to report, such as ERROR_MOD_NOT_FOUND (126) and ERROR_PROC_NOT_FOUND (127). Using a debugger, you can see the name of the missing DLL or procedure if loader snaps are enabled for the application.
History
Date User Action Args
2021-02-09 04:29:25eryksunsetrecipients: + eryksun, paul.moore, tim.golden, zach.ware, steve.dower, jmoguill2
2021-02-09 04:29:25eryksunsetmessageid: <1612844965.67.0.138996977709.issue43173@roundup.psfhosted.org>
2021-02-09 04:29:25eryksunlinkissue43173 messages
2021-02-09 04:29:25eryksuncreate