开发者

ctypes on windows: depending dlls not found

I try to load a shared libraray "R.dll" which depends on "Rblas.dll", both are in the same directory. When I load R.dll with ctypes (a python module which loads shared libraries)

import ctypes
li开发者_高级运维b = ctypes.CDLL("/path_to_r/bin/i386/R.dll")

I get an error message saying that "Rblas.dll" is not found.

What can I do ? I thought that putting both libs in the same directory is enough.


You may need to add the path that the dlls are located at to the %PATH% environmental variable. While R.DLL is loadng with an explicit path, the search for it's requested RBLAS.DLL is still searching %PATH% for it's location. Since that's a Windows level operation, there's no (easy) way to intercept and modify it from python... so changing %PATH% is required.

Though alternately, you could temporarily os.chdir to the desired directory, load the dlls, and restore the original value of os.getcwd after the dlls have loaded.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜