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.
Advertisement
Answer
You only need to do either an export of
PYTHONPATH
or an install of the API (python setup.py install), but not bothSince you are on Linux, it won’t find a
python.exe
, using justpython
should workThe “Path/To/GAMS” is the GAMS system directory. In your case:
/home/my_name/gams35.1_linux_x64_64_sfx