Topic
6 replies Latest Post - ‏2007-08-17T12:19:52Z by SystemAdmin
SystemAdmin
SystemAdmin
2077 Posts
ACCEPTED ANSWER

Pinned topic Eclipse PyDev Plugin

‏2007-07-20T16:04:14Z |
Hello

i want to develop Python in Eclipse with the PyDev Plugin. So i copied the the following py-Files to Python24\Lib\site-packages\ :
spssaux.py
spssdata.py
viewer.py

First i implement the Packages:



import

spss
import spssaux

When i write spss. then the methods are displayed.
But when i write spssaux. no method are displayed. Is this normal? Or must i configure something else?

On another Computer with the same Python-version, eclipse-version and SPSS+Plugin-Version nothing is displayed - even when i write spss. .

What could be the reason?

Another question:
Is it possible to start a "spss-routine" in Eclipse? I develop something in Eclipse and start the programm in it. Now Spss should start, then do something and displays perhabs the result.... --> if this is possible, where can i find an example?

Thank you
Best regards
Frank
Updated on 2007-08-17T12:19:52Z at 2007-08-17T12:19:52Z by SystemAdmin
  • SystemAdmin
    SystemAdmin
    2077 Posts
    ACCEPTED ANSWER

    Eclipse PyDev Plugin

    ‏2007-07-20T16:30:38Z  in response to SystemAdmin
    If your Python IDE can find the package, it should display the docstrings and function help tips for the module. Are you sure that the import spssaux succeeded?


    Try typing

    spssaux

    in the interactive window. It should display something like

    <module 'spssaux' from 'c:/python24/lib/site-packages/spssaux\spssaux.pyc'>

    if it succeeded.


    If it didn't succeed, the spssaux module is probably not in a place where Python will find it. Put it in site-packages to make sure or add the location to your Python search path by using the sitecustomize.py file or another technique. Saving spssaux in the spss subdirectory of site-packages will not work, because Python only looks in subdirectories for modules with names that match the directory.


    I have not used PyDev in quite a while as I prefer other Python IDEs, but I know that the module methods are displayed in

    Pythonwin and WingIDE, which are the ones I use regularly.


    For the spss module, the help is actually incomplete, because that module dynamically loads some other modules, and these tend not to show up in the help, but the spssaux module doesn't have that problem.


    As for the second question, yes, you can easily control SPSS from another application. Just do something like

    import spss

    spss.Submit("some command")


    The issue is how to control the output. By default, the output returns as text and gets displayed in your output window. While this is useful for debugging, you probably don't want to build an app that way. Use spss.SetOutput("off") to stop that.


    Then, the way you get output from SPSS when in this "external drives" mode is via OMS writing to the xmlworkspace.

    You can do that explicitly by issuing OMS commands via Submit and specifying xmlworkspace as the destination and retriving the xml with spss.EvaluateXPath().


    But it is easier in most cases to control this through the spssaux functions

    createXmlOutput

    and

    GetValuesFromXMLWorkspace


    Using SPSS this way leaves it up to your program to handle display.


    You can also use the SPSS COM interfaces (on Windows) to drive SPSS as a separate application with the user interface and Viewer window exposed. See the viewer module on Developer Central if you want to get an idea about that. Post back if you want to discuss that approach further.


    HTH,

    Jon Peck
  • SystemAdmin
    SystemAdmin
    2077 Posts
    ACCEPTED ANSWER

    Eclipse PyDev Plugin

    ‏2007-07-26T14:28:56Z  in response to SystemAdmin

    Hello Jon,


    i tried the following in Eclipse:


    import spss
    spss.Submit("GET FILE='C:/SpssPython/10000Faelle.sav'."
    TotalCases=spss.GetCaseCount()
    print "The file has: " + str(TotalCases) + " cases."



    The following error-message is displayed:



    Traceback (most recent call last):
    File "C:\Dokumente und Einstellungen\V990590\Eigene Dateien\Programmieren\Python\test\src\root\nested\spssAufrufen.py", line 3, in ?


    spss.Submit("GET FILE='C:/SpssPython/10000Faelle.sav'.")
    File "C:\Programme\Python24\lib\site-packages\spss\spss.py", line 1020, in Submit


    StartSPSS()
    File "C:\Programme\Python24\lib\site-packages\spss\spss.py", line 154, in StartSPSS


    raise SpssError,error


    spss.errMsg.SpssError: errLevel 19 SPSS is not licensed (failed to get license for SPSS Base).



    We have a network licence server from which we get the licences of SPSS. But i tried this local because on the spss-server there is no python installed. And the file of the "local-" licence (lservrc) is of course empty. Do i need a local licence in it? Must i change the spssprod.inf also?

    i have now a licence in lservrc but the same error-message is displayed. Must i change something else?


    Thank you very much
    Best regards
    Frank

  • SystemAdmin
    SystemAdmin
    2077 Posts
    ACCEPTED ANSWER

    Eclipse PyDev Plugin

    ‏2007-07-30T00:12:14Z  in response to SystemAdmin
    You need an SPSS license where the plug-in is running, and Python always runs in the "backend" context, so for a Server job, you will need Python on the Server. In local mode, you need a license on the client (and Python on the client, too). If you think you have the right licenses, please contact SPSS Technical Support as they know how to diagnose licensing problems.


    HTH,

    Jon Peck
  • SystemAdmin
    SystemAdmin
    2077 Posts
    ACCEPTED ANSWER

    Eclipse PyDev Plugin

    ‏2007-08-01T12:52:52Z  in response to SystemAdmin

    Hello Jon,

    thank you very much
    Best reganrds
    Frank

  • SystemAdmin
    SystemAdmin
    2077 Posts
    ACCEPTED ANSWER

    Eclipse PyDev Plugin

    ‏2007-08-06T19:47:56Z  in response to SystemAdmin
    I tried using Pydev and Komodo and cannot get the spss module code completion to work correctly. You mentioned in this post that there is an issue in that the spss module uses other modules and that, in turn, causes the code completion to fail. Is there any workaround for this?

    Thanks!
  • SystemAdmin
    SystemAdmin
    2077 Posts
    ACCEPTED ANSWER

    Eclipse PyDev Plugin

    ‏2007-08-17T12:19:52Z  in response to SystemAdmin
    The solution for the error message is described in the SPSS Knowledge basis: 66711. Or in the forum:
    errLevel 19 SPSS is not licenced (failed to get license for SPSS base)

    Now i can do the following in Eclipse and it works:

    import

    spss, spssaux
    spss.Submit(
    "GET FILE='C:/SpssPython/10000Faelle.sav'.")
    TotalCases=spss.GetCaseCount()
    print "The file has: " + str(TotalCases) + " cases."


    Frank