简体   繁体   中英

Is the function os. add_dll_directory() adding directories permanently?

For loading DLL libraries in Python 3.8+ I understand the the path environemnt variable is not used anymore to search for dependencies. Therefore the function os. add_dll_directory() should be used to add directories to the search path. That works on my machine.

Is it possible that the directories are added permanently? I have noticed that now everything is loaded correctly also without adding the dll directory first using the function mentioned. I cannot reproduce the error where the dependencies were not found.

From the documentation I did not understand that anything is changed permanently.

[Python.Docs]: os.add_dll_directory(path) calls [MS.Docs]: AddDllDirectory function (libloaderapi.h) which states ( emphasis is mine):

Adds a directory to the process DLL search path.

So, it has effect during the lifetime of the calling process, or (according to Python doc ) until the returned object is closed (in that case RemoveDllDirectory is called under the hood) either manually or at with statement exit.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM