Closed balasubramaniansa closed 1 year ago
I had the same issue from running the ReEDS model on Windows. I presume this is what you are trying to do as I saw your post on the GAMS World Forum. I'm using Python 3.9.7 and GAMS 38.1.0.
I think what caused my problem is similar to #82 where os.environ.get('GAMSDIR')
resulted in multiple directories C:\GAMS\38;C:\GAMS\38\gbin
. Unfortunately, #83 didn't fix this issue for me - I think the if not os.path.exists(ret)
part may have set my ret
to None.
Under the section def __find_gams(self)
, I added a line after ret = os.environ.get('GAMSDIR')
to manually select my first directory and drop the rest: ret,ret2 = ret.split(";",1)
- this has allowed my ReEDS model to run, phew! As this is a very primitive fix and might be too specific to me, I'm not going to commit the code.
Hope this could be helpful to you. Good luck!
Thanks a lot for your reply. I was able to solve that error some time ago.
The following are a few of my experiences
GAMS installation
In the system which requires administrative access for GAMS installation, if we install the GAMS only for the local system without administrative access, in the automatic installation mode, the GAMS_DIR Environment variable is not automatically getting added to the path Environment variable. In this case, if we check the GAMS status in the command prompt, it shows the installation however it is showing the unable to locate GAMS directory – None Error doing ReEDS run.
When Installing the GAMS, if automatic installation mode is used, there is an option to automatically add to the path environment variable. In this case, the path was added under GAMSDIR and not GAMS_DIR. In the automatic mode, it adds two directories, and I deleted the second one, including the trailing semi-colon.
So, doing the automatic installation with administrative access, editing the GAMSDIR to GAMS_DIR, and deleting the second directory, including the trailing semicolon, worked for me.
Hi!
`#%% 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.todataframe(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.
I am using Python 3.9.7 and GAMS 37.
any suggestions?