_gdxcc.so issue

Questions on using the GAMS APIs (Python, .NET, etc.)
Post Reply
davidwogan
User
User
Posts: 7
Joined: 5 years ago
Location: Tokyo, Japan
Contact:

_gdxcc.so issue

Post by davidwogan »

Hi all,

I am trying to set up my machine to use the Python API. I am following along the Tutorial and am having issues running transport1.py script after installing the API and packages. I receive the following message when trying to run the script:

Code: Select all

Davids-MacBook:python davidwogan$ python transport1.py
Traceback (most recent call last):
  File "/Users/davidwogan/anaconda3/lib/python3.6/site-packages/gdxcc.py", line 14, in swig_import_helper
    return importlib.import_module(mname)
  File "/Users/davidwogan/anaconda3/lib/python3.6/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 994, in _gcd_import
  File "<frozen importlib._bootstrap>", line 971, in _find_and_load
  File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 658, in _load_unlocked
  File "<frozen importlib._bootstrap>", line 571, in module_from_spec
  File "<frozen importlib._bootstrap_external>", line 922, in create_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
ImportError: dlopen(/Users/davidwogan/anaconda3/lib/python3.6/site-packages/_gdxcc.so, 2): Symbol not found: _PyClass_Type
  Referenced from: /Applications/GAMS25.0/sysdir/_gdxcc.so
  Expected in: flat namespace
 in /Applications/GAMS25.0/sysdir/_gdxcc.so

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "transport1.py", line 10, in <module>
    from gams import *
  File "/Users/davidwogan/anaconda3/lib/python3.6/site-packages/gams/__init__.py", line 8, in <module>
    from .workspace import *
  File "gams/workspace.py", line 8, in init gams.workspace (workspace.c:20144)
  File "gams/database.py", line 2, in init gams.database (database.c:51898)
  File "/Users/davidwogan/anaconda3/lib/python3.6/site-packages/gdxcc.py", line 17, in <module>
    _gdxcc = swig_import_helper()
  File "/Users/davidwogan/anaconda3/lib/python3.6/site-packages/gdxcc.py", line 16, in swig_import_helper
    return importlib.import_module('_gdxcc')
  File "/Users/davidwogan/anaconda3/lib/python3.6/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
ImportError: dlopen(/Users/davidwogan/anaconda3/lib/python3.6/site-packages/_gdxcc.so, 2): Symbol not found: _PyClass_Type
  Referenced from: /Applications/GAMS25.0/sysdir/_gdxcc.so
  Expected in: flat namespace
 in /Applications/GAMS25.0/sysdir/_gdxcc.so
According to the traceback the issue is with opening _PyCLass_Type in _gdxcc.so . I searched on this forum and found an example where a user had a dlopen issue (viewtopic.php?f=10&t=10219&p=23399&hilit=dlopen#p23399). I tried the Xcode command line procedure but am still experiencing the error above.

I am using Python 3.6 from Anaconda and GAMS 25.0 on OX 10.13.4. Is this a bug or is there something I am missing? Thanks in advance,

David Wogan
David
Asia Pacific Energy Research Centre (APERC)
User avatar
Clemens
Posts: 57
Joined: 7 years ago

Re: _gdxcc.so issue

Post by Clemens »

David,

The file _gdxcc.so is required by the Object-oriented Python API. GAMS distributes different version of the file for the different API versions (Python 2.7, 3.6, etc.) and one version which is located directly in the GAMS system directory (/Applications/GAMS25.0/sysdir/). This version of the file is only required by certain tools that are shipped with GAMS but not for the Object-oriented API.
Your error message indicates that the GAMS API was installed in the site-packages location of your Python interpreter. Anyhow, the API tries to load the _gdxcc.so library from the wrong location (/Applications/GAMS25.0/sysdir/) instead of the correct location (/Users/davidwogan/anaconda3/lib/python3.6/site-packages/).
Assuming that the installation was done correctly using the command 'python setup.py install' in the directory '/Applications/GAMS25.0/sysdir/apifiles/Python/api_36', the cause of the problem might be a misconfigured PYTHONPATH environment variable that points to your GAMS system directory. You might check the content of this environment variable using the command 'echo $PYTHONPATH' from the Terminal.

Let me know if this helps,
Clemens
davidwogan
User
User
Posts: 7
Joined: 5 years ago
Location: Tokyo, Japan
Contact:

Re: _gdxcc.so issue

Post by davidwogan »

Hi Clemens,

Thanks for your reply. The API should be installed properly (I ran 'python setup.py install' in '/Applications/GAMS25.0/sysdir/apifiles/Python/api_36').

When echoing $PYTHONPATH it comes up empty.

The error persists when pointing to /Users/davidwogan/anaconda3/lib/python3.6/site-packages/.

Any other ideas? Has anyone using Anaconda experienced issues with getting it to work (by following the Tutorial)? Thanks in advance,

David
David
Asia Pacific Energy Research Centre (APERC)
davidwogan
User
User
Posts: 7
Joined: 5 years ago
Location: Tokyo, Japan
Contact:

Re: _gdxcc.so issue

Post by davidwogan »

Update!

I now know the cause of the error. In following the Tutorial, I read the instructions for OS X as setting both the PATH and DYLD_LIBRARY_PATH variables. Only one needs to bet set otherwise there is a conflict. This is mentioned in the tutorial "OS X: Try to find a system directory in the PATH first. If none was found, search DYLD_LIBRARY_PATH." but perhaps it could be made more explicit for OS X users.

Thanks for the help, Clemens.

David
David
Asia Pacific Energy Research Centre (APERC)
Post Reply