View Full Version : Using Python modules

2012-04-03, 21:01
Where do I need to copy Python modules to so I can use them in my Python code in Lianja?

2013-11-16, 18:56
Please advice on how I can make use of Python to access/determine the serial number of a USB drive.
I am aware that I can make use of microsoft WMI (Windows Management Instrumentation) but I stumble on how to perform the imports of the modules required. The resources I am looking at is http://timgolden.me.uk/python/wmi/index.html This shows need to use pywin32 that is where I can't figure out how to add to Lianja.

2013-11-16, 22:07
Hi Cox,


This is the path used by python which is setup in the registry when you install Lianja.

HKEY_LOCAL_MACHINE\SOFTWARE\Python\PythonCore\2.7\ PythonPath
C:\lianja\scriptinglanguages\python\Lib;C:\lianja\ scriptinglanguages\python\DLLs;C:\lianja\scripting languages\python\Lib\lib-tk

2013-11-20, 07:52
I am trying to run a for in range loop python as follows via a command

for num in range(5):

p.s, there is a tab before th Lianja.writeLog.

not getting any output in the log.
running RC10

2013-11-20, 08:50
Hello Cox,

Try it from the python tab in the console workspace.

2013-11-20, 09:09

Lianja.writeLog() takes a string.



2013-11-26, 10:16
I have managed to gather system details using python & vbscript and during this exercise, found that I did need to make use of modules that are not default in the lianja distribution (hence moved to next solution). Could a breakdown on how this is achieved be put forward please since copying a given directory into the python/lib didn't work for me.
Most of the documentations talked about installing the module to the current python on system, but as a distributed python, couldn't figure this out.

Of interest was pywin32.


Need: To get unique serial number (Manufacture number) associated with a USB key.

2013-11-26, 12:58
Hi Cox,

I was able to use the msi installer for pywin32, but I had to change a couple of the Registry entries created by the Lianja for Python to do so. (I'll get these checked out for final release.)

I'm on Win64, so I have:


on Win32 the root will be (applies to the entries that follow):


The Lianja installer puts InstallPath here:

HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Python\Pyt honCore\InstallPath

but I think it should be one level lower, i.e.

HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Python\Pyt honCore\2.7\InstallPath

and the (Default) string value it contains should be the python folder under Lianja. For a default installation, this is:


Also, this:

HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Python\Pyt honCore\2.7\InstallPath\InstallGroup

should have the (Default) string value of:

Python 2.7



Note: the Forum editor is adding a space in 'PythonCore' - there should be no space.

2013-11-27, 16:16
Please see images, I have made the registry changes as shown,

and tried to install WMI-1.4.9.win32 (https://pypi.python.org/pypi/WMI/#downloads). as shown in the install pane, the entry for installation directory is as follows (C:\Lianja\scriptinglanguages\python\Lib\site-packages\)

Have tried at the console to run

import wmi, but getting error

Wed 27. Nov 21:12:30 2013
**** Lianja Python error ****
Traceback (most recent call last):
File "Console" at line 1, in <module>
File "C:\Lianja\scriptinglanguages\python\lib\site-packages\wmi.py" at line 88, in <module>
from win32com.client import GetObject, Dispatch
ImportError: No module named win32com.client

2013-11-28, 07:51
Hi Cox,

It looks like you don't yet have pywin32 installed and wmi sits on top of it. Once you have pywin32 installed, copy the dlls from C:\Lianja\scriptinglanguages\python\Lib\site-packages\pywin32_system32 into your Windows System folder and you should be up and running.



2013-11-28, 15:00
Thanks, that sort it. just needed to add the dll's to systems directory. Just to confirm now that a published application when moved to a new machine will have these covered...

2013-11-29, 08:15
Hi Cox,

Calling the following as administrator, should also do it (default Lianja installation path used here):

cd c:\lianja\bin
c:\lianja\scriptinglanguages\python\python c:\lianja\scriptinglanguages\python\scripts\pywin3 2_postinstall.py -quiet -install