GmatBase Exception Thrown: cannot call python function

Post here for assistance in troubleshooting a problem using GMAT

GmatBase Exception Thrown: cannot call python function

Postby tracie » Wed Mar 29, 2017 12:19 am

On Windows, I've installed the 32-bit version of GMAT and the 32-bit version of Python 3.6.1. I can't get the simplest python function call to work.

Minimal code example:

Code: Select all
Create Variable x
BeginMissionSequence
x = Python.MathFunctions.sqrt(2)


In reference to the above script, MathFunctions.py comes with GMAT and is in the userfunctions\python directory. The sqrt() function is that file.

Per the GMAT help documentation (page 897), I've set the PYTHONPATH environment variable as:
PYTHONPATH=C:\Program Files (86)\Python36-32\Lib\site-packages

and my PATH environment variable contains the install location of Python and the /Scripts directory.

Executing the above example script yields:

Exception Thrown: The Moderator cannot create a Command type "CallPythonFunction"
in line:
" 3: x = Python.MathFunctions.sqrt(2)"


Without any better ideas, I tried adding:
Code: Select all
Create PythonFunction sqrt
to the top of the script; no joy.

I would very much welcome any suggestions for how to enable python calls from a GMAT script. Thanks in advance!
tracie
 
Posts: 2
Joined: Tue Mar 28, 2017 11:51 pm

Re: GmatBase Exception Thrown: cannot call python function

Postby tracie » Tue Apr 18, 2017 6:45 pm

For whoever comes after me: This error was due to using the latest version of python. As stated in the documentation: "GMAT is built and tested with Python 3.4.3. The interface is linked with the Python binary libraries, so the installed version of Python on the user's machine must match the architecture and release used to build GMAT."

Reverting back to Python 3.4.3 (and updating environment variables accordingly) resolved this issue.
tracie
 
Posts: 2
Joined: Tue Mar 28, 2017 11:51 pm

Re: GmatBase Exception Thrown: cannot call python function

Postby jlin » Fri Jul 07, 2017 6:32 pm

Thank you so much! I tried everything that I could think of, as well as followed all the instructions. Reverting back to 3.4.3 was the only way to get it to work.

Just to add, for anyone else. For the 2017a release I remember to upgrade to 3.6.x (I used 3.6.3).
jlin
 
Posts: 9
Joined: Fri Jul 07, 2017 6:28 pm


Return to Troubleshooting

Who is online

Users browsing this forum: Baidu [Spider] and 1 guest