Page 1 of 2 12 LastLast
Results 1 to 10 of 12

Thread: Using Python modules

  1. #1
    Lianja Support Team lianjasupport's Avatar
    Join Date
    Feb 2012
    Location
    Boston USA, Wokingham UK
    Posts
    1,259

    Using Python modules

    Where do I need to copy Python modules to so I can use them in my Python code in Lianja?

  2. #2
    Member
    Join Date
    Aug 2013
    Location
    United Kingdom
    Posts
    48
    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.

  3. #3
    Lianja Development Team barrymavin's Avatar
    Join Date
    Feb 2012
    Location
    UK, USA, Thailand
    Posts
    7,184
    Blog Entries
    22
    Hi Cox,

    C:\lianja\scriptinglanguages\python\Lib

    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
    Principal developer of Lianja, Recital and other products

    Follow me on:

    Twitter: http://twitter.com/lianjaInc
    Facebook: http://www.facebook.com/LianjaInc
    LinkedIn: http://www.linkedin.com/in/barrymavin

  4. #4
    Member
    Join Date
    Aug 2013
    Location
    United Kingdom
    Posts
    48
    I am trying to run a for in range loop python as follows via a command

    for num in range(5):
    Lianja.writeLog(num)

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


    not getting any output in the log.
    running RC10

  5. #5
    Lianja Development Team barrymavin's Avatar
    Join Date
    Feb 2012
    Location
    UK, USA, Thailand
    Posts
    7,184
    Blog Entries
    22
    Hello Cox,

    Try it from the python tab in the console workspace.
    Principal developer of Lianja, Recital and other products

    Follow me on:

    Twitter: http://twitter.com/lianjaInc
    Facebook: http://www.facebook.com/LianjaInc
    LinkedIn: http://www.linkedin.com/in/barrymavin

  6. #6
    Lianja Team yvonne.milne's Avatar
    Join Date
    Feb 2012
    Location
    Berkshire, UK
    Posts
    1,843
    Hi,

    Lianja.writeLog() takes a string.

    Regards,

    Yvonne

  7. #7
    Member
    Join Date
    Aug 2013
    Location
    United Kingdom
    Posts
    48
    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.

    http://sourceforge.net/projects/pywin32/

    Need: To get unique serial number (Manufacture number) associated with a USB key.
    Last edited by Cox; 2013-11-26 at 09:24.

  8. #8
    Lianja Team yvonne.milne's Avatar
    Join Date
    Feb 2012
    Location
    Berkshire, UK
    Posts
    1,843
    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:

    HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Python

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

    HKEY_LOCAL_MACHINE\SOFTWARE\Python

    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:

    C:\Lianja\scriptinglanguages\python\

    Also, this:

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

    should have the (Default) string value of:

    Python 2.7

    Regards,

    Yvonne

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

  9. #9
    Member
    Join Date
    Aug 2013
    Location
    United Kingdom
    Posts
    48
    Please see images, I have made the registry changes as shown,

    Name:  installing module-Registry settings.win32.jpg
Views: 363
Size:  74.7 KB
    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\)
    Name:  installing module-WMI-1.4.9.win32.jpg
Views: 258
Size:  31.1 KB

    Have tried at the console to run

    import wmi, but getting error

    Code:
    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

  10. #10
    Lianja Team yvonne.milne's Avatar
    Join Date
    Feb 2012
    Location
    Berkshire, UK
    Posts
    1,843
    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.

    Regards,

    Yvonne

Bookmarks

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Journey into the Cloud
Join us