Python API Installation User Folder

Questions on using the GAMS APIs (Python, .NET, etc.)
Post Reply
Jan
User
User
Posts: 10
Joined: 7 years ago

Python API Installation User Folder

Post by Jan »

Hi,

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 setup.py, i.e.,

Code: Select all

python setup.py 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/_gdxcc.so: 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 gamsxsetup.py also works, but when I try to import the gams package, I get an import error:
ImportError: gams/workspace.so: undefined symbol: PyUnicodeUCS4_FromStringAndSize
Any hints how to install the gams package to the user "site-packages" folder?

Best
Jan

P.S. Gams version: 24.9.1; Python 2.7.
User avatar
Clemens
Posts: 57
Joined: 7 years ago

Re: Python API Installation User Folder

Post by Clemens »

Hello,

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'
else:
    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.

Best,
Clemens
Post Reply