Question

I installed CPLEX 12.5 on a RHEL6.3 machine (x86 64bit) and it seems to be running fine. However, when I try to use the Python API, I get the following error:

>>> import cplex
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "cplex/__init__.py", line 43, in <module>
    import callbacks
  File "cplex/callbacks.py", line 48, in <module>
    from _internal._aux_functions import apply_freeform_two_args, apply_freeform_one_arg
  File "cplex/_internal/__init__.py", line 22, in <module>
    import _list_array_utils
  File "cplex/_internal/_list_array_utils.py", line 13, in <module>
    import _pycplex as CPX
  File "cplex/_internal/_pycplex.py", line 19, in <module>
    _pycplex_platform = swig_import_helper()
  File "cplex/_internal/_pycplex.py", line 15, in swig_import_helper
    _mod = imp.load_module('_pycplex_platform', fp, pathname, description)
  File "cplex/_internal/_pycplex_platform.py", line 39, in <module>
    from cplex._internal.py1013_cplex125 import *
ImportError: cplex/_internal/py1013_cplex125.so: undefined symbol: PyUnicodeUCS4_Decode

Any pointers on what I might be doing wrong?

[~] python -c 'import struct; print struct.calcsize("P") * 8'
64
Was it helpful?

Solution

I figured out what was wrong. Python had the incorrect Unicode build type:

>>> import sys;print((sys.maxunicode<66000)and'UCS2'or'UCS4')
UCS2

So I recompiled it using --enable-unicode=ucs4, and now the module imports fine.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top