I’m trying to install the GAMS Python API using Anaconda, but it is picking up an old version of GAMS (38) that I have installed on my machine. I have GAMS 38-46 currently installed, and am trying to use the api with Gams 46.4.0, the latest version installed on my machine.
I started by creating a new environment in Anaconda, and in a command line entered:
(gams_py46) C:\Users\myusername>pip install gamsapi[all]==46.4.0
which seemed to install successfully. Then (following the instructions in https://www.gams.com/latest/docs/API_PY_GETTING_STARTED.html), I entered
python -c "import gams; print(f'API OK -- Version {gams.__version__}')"
which gave me
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "C:\GAMS\38\apifiles\Python\gams\gams\__init__.py", line 32, in <module>
from .workspace import *
File "C:\GAMS\38\apifiles\Python\gams\gams\workspace.py", line 32, in <module>
from .database import *
File "C:\GAMS\38\apifiles\Python\gams\gams\database.py", line 26, in <module>
from gdxcc import *
ModuleNotFoundError: No module named 'gdxcc'
so clearly it is trying to get something from GAMS 38 instead of GAMS 46. So I tried
(gams_py46) C:\Users\myusername>python -m site
and got
sys.path = [
'C:\\Users\\myusername',
'C:\\GAMS\\38\\apifiles\\Python\\gams',
'C:\\Users\\myusername\\%PYTHONPATH%',
'C:\\Anaconda3\\envs\\gams_py46\\python311.zip',
'C:\\Anaconda3\\envs\\gams_py46\\DLLs',
'C:\\Anaconda3\\envs\\gams_py46\\Lib',
'C:\\Anaconda3\\envs\\gams_py46',
'C:\\Anaconda3\\envs\\gams_py46\\Lib\\site-packages',
]
USER_BASE: 'C:\\Users\\myusername\\AppData\\Roaming\\Python' (exists)
USER_SITE: 'C:\\Users\\myusername\\AppData\\Roaming\\Python\\Python311\\site-packages' (doesn't exist)
ENABLE_USER_SITE: True
The instructions tell me to correct the GAMS path in the file sitecustomize.py, but there is no such file in the USER_BASE folder (and the USER_SITE folder doesn’t exist), and any other files I can find with this name don’t have a C:\GAMS\38 path in them (or any other explicit GAMS path for that matter).
I don’t really want to uninstall GAMS 38 as I need to retain that for the working version of the code I want to upgrade. How do I fix this path issue? Thanks!