Problems running Python with Geosoft

ChrisEykamp
edited October 27 in GX Developer
Hello,

I'm trying to get python up and running, and am getting the error shown below when running the hello world script from the Python menu.  I'm using a fresh install of the Geosoft software (version 9.10), and the installation of python that came with it.  I've installed the Geosoft python libraries in the right place.

I've confirmed that the hello_world.py script that gets installed works in the Anaconda environment installed with Geosoft, so I know the problem is not with python or the required libraries.  Further, when I look at the call stack attached to the message, I can confirm that python is running, and it has been able to load the geosoft libraries I installed.  All that plumbing appears in order.

I am running only one instance of Geosoft, and this occurs even after a fresh boot which eliminates the possibility there is something lingering in memory.  That suggests there is a problem with the way Geosoft is managing the Python environment.

What's more, a colleague is experiencing the same thing, also with 9.10.

Any ideas about what I can do to get python working?

Thanks,

Chris





Tagged:

Answers

  • ChrisEykamp
    edited October 27
    I have a provisional solution: my new theory is that the problem is with the hello_world.py script itself.  I can make it work by inserting the lines marked with a ##:

    import geosoft.gxapi as gxapi
    import geosoft.gxpy as gxpy
    
    # a python script must have a rungx(), which is executed by OM when the script is run
    def rungx():
    
        # get the current gx context
        try:                        ##
            gxp = gxpy.gx.gx()      ##
        except gxapi.GXAPIError:    ##
            gxp = gxpy.gx.GXpy()   
    
        # say hello to the user identified by gxp.gid.
        gxapi.GXSYS.display_message("GX Python", "Hello {}".format(gxp.gid))
    
    if __name__ == "__main__":
        gxc = gxpy.gx.GXpy()
        print('Hello {}'.format(gxc.gid))

    Does anyone have a thought about whether this is the proper solution, and whether this is simply a case of broken sample code?