PDA

View Full Version : Import python module DLL location



jmartyr
2016-01-06, 23:52
Hi all,

Just wondering where to put python DLLs (.pyd) that are called in python modules we want to import? I've tried putting them in both .../Lianja/scriptinglanguages/python/DLLs and in .../Lianja/scriptinglanguages/python/Lib. In the "Using Python Modules" thread on here it mentions registry key editing and I've followed those instructions as well. What is happening now is:


I have a python DLL "mydll.pyd" in the 2 folders mentioned above
I have a script "myscript.py" in .../Lianja/scriptinglanguages/python/Lib which has at the top:


import mydll

When I run
import myscript in the Lianja Python console, it pops out:


**** Lianja Python error ****
Traceback (most recent call last):
File "Console" at line 1, in <module>
File "C:\lianja\scriptinglanguages\python\lib\myscript.p y" at line 7, in <module>
import mydll
ImportError: DLL load failed: The specified module could not be found.


Has anyone had success importing python dlls? How did you do it?

Thanks.

barrymavin
2016-01-07, 02:59
If the python DLL has been built against the version of Python supported in Lianja (which is 2.7 on windows) it works by just placing the DLL in the DLL directory.

You can verify this from the Python console.

import sqlite3

where sqlite3.dll exists in C:\lianja\scriptinglanguages\python\DLLs

If you exit Lianja and rename the sqllite3.dll to xxx_sqlite3.dll and then run Lianja again and do the same sequence of steps the DLL will not be found.

So...

The DLL must be a 32-bit DLL not a 64-bit version, and it must be compatible with Python 2.7.

See screenshots working and then not working by renaming the sqlite3.dll file.

1209

1208