1

I'm sure this problem is pretty basic but this is my first time trying to run gams via python on Linux so I'd appreciate some help. My problem seems to be that I cannot properly link the GAMS directory. When I tried to

from gams import *

I got an error:

ModuleNotFoundError: No module named 'gams'

I'm trying to run this on a cluster (Linux). I can get it to work just fine on my personal laptop (Windows). What I did was I downloaded and installed GAMS Linux version to my directory on the cluster. The directory is /home/my_name/gams35.1_linux_x64_64_sfx/

My python code is a master.py file in another folder: /home/my_name/projects/project_3/Model/Python/

I tried to follow the tutorial on https://www.gams.com/latest/docs/API_PY_TUTORIAL.html. So first:

export PYTHONPATH=/home/my_name/gams35.1_linux_x64_64_sfx/apifiles/Python/api_38
export PYTHONPATH=/home/my_name/gams35.1_linux_x64_64_sfx/apifiles/Python/gams:$PYTHONPATH

Next, I need to copy the GAMS Python files to the Python installation, so:

cd /home/my_name/gams35.1_linux_x64_64_sfx/apifiles/Python/api_38
/home/my_name/.conda/pkgs/python-3.8.8-hdb3f193_5/bin/python.exe setup.py install

Here I got the first error of No such file or directory. So I can't find where the python.exe file is on my .conda directory. Then I would definitely have issue with the final step which is to specify a gams system directory:

export PATH=<Path/To/GAMS>:$PATH

What is the Path/To/GAMS supposed to be in my case? I tried all /home/my_name/gams35.1_linux_x64_64_sfx, /home/my_name/gams35.1_linux_x64_64_sfx/apifiles/Python/api_38, /home/my_name/gams35.1_linux_x64_64_sfx/apifiles/Python/gams, and got errors of no such file or directory in all

Any help is appreciated! Thanks very much in advance.

user496181
  • 141
  • 7

1 Answers1

2
  1. You only need to do either an export of PYTHONPATH or an install of the API (python setup.py install), but not both

  2. Since you are on Linux, it won't find a python.exe, using just python should work

  3. The "Path/To/GAMS" is the GAMS system directory. In your case: /home/my_name/gams35.1_linux_x64_64_sfx

Lutz
  • 2,197
  • 1
  • 10
  • 12
  • Thank you! I was able to specify the gams directory using export PATH=. However when I tried to run the transportation example in apifiles/Python. I still get an error: "GAMS system directory not found or invalid. You need to set either PATH or LD_LIBRARY_PATH to a valid GAMS system directory or to specify one in the Gamsworkspace constructor" so it looks like my gams system directory is still not found on PATH? – user496181 May 20 '21 at 16:20
  • As mentioned in the [tutorial](https://www.gams.com/latest/docs/API_PY_TUTORIAL.html#PY_CHOOSE_GAMS_SYSTEM), there are two ways to specify the system directory. Maybe try to specify in the workspace constructor explicitly. If that works, you know at least the it works in general. Next, I would print the PATH in your Python example to see what it sees there, and maybe see a problem. – Lutz May 21 '21 at 06:34
  • Thanks. After trying everything correctly and still have an error, it turned out the issue is my gams license cannot be used with the new version of gams that i just downloaded. – user496181 May 27 '21 at 18:16