Python API error message

Questions on using the GAMS APIs (Python, .NET, etc.)
Post Reply
petephuang
User
User
Posts: 2
Joined: 2 weeks ago

Python API error message

Post by petephuang » 2 weeks ago

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

User avatar
Clemens
Posts: 52
Joined: 4 years ago

Re: Python API error message

Post by Clemens » 5 days ago

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

petephuang
User
User
Posts: 2
Joined: 2 weeks ago

Re: Python API error message

Post by petephuang » 1 day ago

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

Post Reply