Python API Installation User Folder

Questions on using the GAMS APIs (Python, .NET, etc.)
Posts: 4
Joined: 1 year ago

Python API Installation User Folder

Postby Jan » 2 weeks ago


I am trying to install the Python API on a Linux server. Python is installed server and I do not have writing access to the standard "site-packages" folder. I thus need to install to the user "site-packages" folder. When I use the option for this in calling, i.e.,

Code: Select all

python install --user
in the bash (in folder in which API files are located), I get an error message:
error: /cluster/apps/python/2.7.6/x86_64/lib64/python2.7/site-packages/ Permission denied
as this is the path to the server "site-packages" folder.

I tried running the different setup files for the low level packages (gdxcc etc.) and these packages correctly install in the user "site-packages" folder. Finally running also works, but when I try to import the gams package, I get an import error:
ImportError: gams/ undefined symbol: PyUnicodeUCS4_FromStringAndSize
Any hints how to install the gams package to the user "site-packages" folder?


P.S. Gams version: 24.9.1; Python 2.7.

Posts: 10
Joined: 1 year ago

Re: Python API Installation User Folder

Postby Clemens » 1 week ago


Thank you for providing the "--user" problem. We will look into this and see how to fix this. Most likely it is a problem in our setup scripts. Note that you can also always set the PYTHONPATH in order to tell the Python interpreter where to look for modules.
The actual problem you are facing now is a mismatch between the Unicode setting of the Python interpreter and the GAMS Python API. We distribute the GAMS Python API in binary files which use UCS4 on Mac and Linux. Therefore sysconfig.get_config_var('Py_UNICODE_SIZE') should evaluate to 4. An alternative way to check the unicode settings is as follows:

Code: Select all

import sys
if sys.maxunicode > 65535:
    print 'UCS4 build'
    print 'UCS2 build'
The unicode versions of the API and the Python interpreter need to match. The only solution is to use an appropriate version of the Python interpreter. You might need to install a UCS4 prebuild package for Linux or even build Python from source. The important flag that triggers UCS4 is --enable-unicode=ucs4.


Who is online

Users browsing this forum: No registered users and 1 guest