Page 1 of 1

Python API error message

Posted: Sun May 30, 2021 11:31 pm
by petephuang
Hi GAMS community,

I ran into an error message while running a python script to read GDX files on my Mac. The error is like:

GamsException: GAMS System directory not found or invalid. You need to set either PATH or DYLD_LIBRARY_PATH to a valid GAMS system directory or to specify one in the GamsWorkspace constructor.

I installed GAMS using the PKG installer (GAMS35.1.0.pkg), and it seems like the GAMS system directory should be automatically specified. When I test the program using the:

gamslib trnsport
gams transport

The terminal runs correctly.

Can you please help me with it?

Best,
Pei Huang

Re: Python API error message

Posted: Thu Jun 10, 2021 1:58 pm
by Clemens
Pei Huang,

The PKG installer on macOS allows to add the GAMS system directory to the PATH variable when a Terminal is opened. You might want to double-check its content using echo $PATH, but since you are able to call gams and gamslib, I guess that this is set up correctly. If you run the python interpreter from a Terminal, the GamsWorkspace constructor should be able to find the system directory automatically. In case you are using some IDE, you might need to separately configure it since macOS does not support system wide environment variables and therefore the PATH might look different. In any case you can always specify the system directory in the GamsWorkspace constructor like this:

Code: Select all

ws = GamsWorkspace(system_directory='/Library/Frameworks/GAMS.framework/Resources')
For more information see the GAMS Python API tutorial, in particular the section about Specifying a GAMS System Directory: https://www.gams.com/latest/docs/API_PY ... MDIRECTORY

Best,
Clemens

Re: Python API error message

Posted: Tue Jun 15, 2021 10:02 am
by petephuang
Dear Clemens,

Thank you very much for your reply! I'm new to MacOS - so I was not very familiar with setting up PATH.

I just tried your solution - setting up the PATH environment variable for the GAMS directory. It worked!

Best,
Pei