rocksportrocker
rocksportrocker

Reputation: 7419

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
lib = 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.

Upvotes: 3

Views: 1031

Answers (1)

Eli Collins
Eli Collins

Reputation: 8533

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.

Upvotes: 4

Related Questions