Issues Importing Gams 24.8.5 From Python 3.6.10

Solver related questions
Post Reply
AlbertoGil
User
User
Posts: 1
Joined: 3 years ago

Issues Importing Gams 24.8.5 From Python 3.6.10

Post by AlbertoGil »

Hello all, thank you in advance for the help,

It previously worked fine, importing GAMS from my python code. I had to update my python from 2.7.15 to 3.6.10 version. Now I got this error:
image.png
If you can not view the image, it says the following:
----------------------------------------------------------------------------------------------------------------------------------------------------------
Traceback (most recent call last):
File "C:\Users\alberto.gil\Anaconda3\envs\optimizador\lib\runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "C:\Users\alberto.gil\Anaconda3\envs\optimizador\lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "C:\Users\alberto.gil\AppData\Roaming\Python\Python36\site-packages\turbybomb\resultados_opt.py", line 3, in <module>
from gams import *
File "C:\Users\alberto.gil\Anaconda3\envs\optimizador\lib\site-packages\gams\__init__.py", line 8, in <module>
from .workspace import *
ImportError: DLL load failed: The specified module could not be found.
----------------------------------------------------------------------------------------------------------------------------------------------------------

I am using GAMS 24.8.5 version. I have the license file in the same directory as previously. And I have installed the GAMS library 1.0 on my conda environment as follow:
- cd C:\GAMS\win64\24.8\apifiles\Python
- cd api_36 && python setup.py install && cd ..

When I ran it I got the error that I have previously shared.

Could you help me please?
evanmirk
User
User
Posts: 1
Joined: 2 years ago

Re: Issues Importing Gams 24.8.5 From Python 3.6.10

Post by evanmirk »

To make it short, it means that you lacked some "dependencies" for the libraries you wanted to use. This is a common problem when installing python packages, mainly in windows. Before trying to use any kind of library, first it is suggested to look up whether it needs another library in python "family".

The solution is to provide the python interpreter with the path-to-your-module/library. The simplest solution is to append that python path to your sys.path list. In your notebook, first try:

import sys
sys.path.append('my/path/to/module/folder')

This isn't a permanent change in sys.path, because when you log out, your environment is reset, so any variables you may have set are lost.

The better (and more permanent) way to solve this is to set your PYTHONPATH, which provides the interpreter with additional directories look in for python packages/modules.

from BASH type: export PYTHONPATH=/path/to/new/folder:/another/path/...../ #each path must be separated by a colon
Post Reply