When calling the GamsWorkspace constructor, the API tries to find a valid GAMS system directory. The exact mechanism for this is depending on the operating system. If you want to specify a system directory explicitly you can do this by providing the named argument system_directory: GamsWorkspace(system_directory="my/sys/dir"). See also the documentation: https://www.gams.com/latest/docs/apis/p ... space.html

I'm testing gams api pyhton with the TRNSPORT.gms example and ran it right on the spyder.
But when I test for another file I created myself (and this file runs correctly on gams.exe), in spyder it gives: gamslib return code not 0 (2)

From your code it seems that the variable COST is zero dimensional, but you try to access key(0) and key(1) which would only be possible for GAMS symbols with at least two dimensions. Instead of doing this:

There is no fundamental difference when accessing records of GAMS Symbols with a dimension greater than zero. You can iterate through the records as you already did and for each record you can access the available information. This is .key(x) where x needs to be between 0 and dimension-1. You get the label in the x-th index position. Furthermore depending on the actual type of the GAMS symbol you can access different attributes which are as follows: