Unable to locate your GAMS directory

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

Unable to locate your GAMS directory

Post by balasubramaniansa »

Hi!
I get the following error when I try to use GAMS and Python

"RuntimeError: Unable to locate your GAMS directory.
Exception ignored in: <function GdxFile.del at 0x0000020E182839D0>"

I am using a windows 10 machine.

My python version is 3.9.7 and GAMS 30.3.

I tried to add GAMS directory to path environment variable still the error persists. I tried to clean the registry and $recycle bin folders to delete all the hidden files. I also removed the cache and still encountering the same error.

Thanks
Bala
abhosekar
Moderator
Moderator
Posts: 295
Joined: 3 years ago

Re: Unable to locate your GAMS directory

Post by abhosekar »

It would be useful to know how you are you trying to use GAMS and python. Are you referring to embedded python? Python API? What are the exact commands that lead to this error?
Are the commands/features you are trying to use supported in your GAMS version 30.3?
- Atharv
balasubramaniansa
User
User
Posts: 2
Joined: 1 year ago

Re: Unable to locate your GAMS directory

Post by balasubramaniansa »

I am working on an open access model (NREL ReEDS). Its in Python API.
The model I ran with Python 3.6.5, Python 3.7, Python 3.9.7 and
GAMS 30.3, GAMS 37, GAMS 40, GAMS 41 with all the possible combinations. The model can run in all these versions. I am using a windows 10 machine.

I am trying to use GDXPDS package to transfer between GDX data and Pandas.

This is the python code.

[code#%% IMPORTS ###
import gdxpds
import pandas as pd
import os
import argparse
#%% direct print and errors to log file
import sys
sys.stdout = open('gamslog.txt', 'a')
sys.stderr = open('gamslog.txt', 'a')
Time the operation of this script
from ticker import toc
import datetime
tic = datetime.datetime.now()
#############
#DUPV
#############
dupv = gdxpds.to_dataframe(gdxfile,'CFDUPV')
dupv = pd.DataFrame(dupv['CFDUPV'])
dupv['c'] = 'dupv_' + dupv.k.str.strip('class')
dupv.columns = ['r','h','cl','value','i']
dupv = dupv[['r','i','h','value']]`
I get the following error.
Traceback (most recent call last):
File "C:\Users\bs43384\Desktop\ReEDS_OpenAccess-main\input_processing\cfgather.py", line 95, in
dupv = gdxpds.to_dataframe(gdxfile,'CFDUPV')
File "C:\Users\bs43384\AppData\Roaming\Python\Python39\site-packages\gdxpds\read_gdx.py", line 143, in to_dataframe
df = Translator(gdx_file,gams_dir=gams_dir,lazy_load=True).dataframe(symbol_name)
File "C:\Users\bs43384\AppData\Roaming\Python\Python39\site-packages\gdxpds\read_gdx.py", line 50, in init
self.__gdx = GdxFile(gams_dir=gams_dir,lazy_load=lazy_load)
File "C:\Users\bs43384\AppData\Roaming\Python\Python39\site-packages\gdxpds\gdx.py", line 154, in init
NeedsGamsDir.init(self,gams_dir=gams_dir)
File "C:\Users\bs43384\AppData\Roaming\Python\Python39\site-packages\gdxpds\tools.py", line 182, in init
self.gams_dir = gams_dir
File "C:\Users\bs43384\AppData\Roaming\Python\Python39\site-packages\gdxpds\tools.py", line 190, in gams_dir
self.__gams_dir = GamsDirFinder(value).gams_dir
File "C:\Users\bs43384\AppData\Roaming\Python\Python39\site-packages\gdxpds\tools.py", line 73, in gams_dir
raise RuntimeError("Unable to locate your GAMS directory.")

RuntimeError: Unable to locate your GAMS directory.
Exception ignored in: <function GdxFile.del at 0x00000243458964C0>``
Unable to load gdxcc with default GAMS directory 'None'. You may need to explicitly call gdxpds.load_gdxcc(gams_dir) before importing pandas to avoid a library conflict.
][/code]
abhosekar
Moderator
Moderator
Posts: 295
Joined: 3 years ago

Re: Unable to locate your GAMS directory

Post by abhosekar »

gdxpds is not a GAMS package (neither developed by gams nor supported by gams). I encourage you to use GAMS Transfer Python .
It is available in all versions starting gams 37 but I encourage you to install GAMS 42 because the installation is easiest. https://www.gams.com/latest/docs/API_PY ... ARTED.html

- Atharv
Post Reply