steph
steph

Reputation: 565

Problems with CPLEX Python API on a mac

I have read many posts about problems but none of them can solve mine. Although I have been following this blog exactly I still get this error when I try to run one of the example src python files:

Traceback (most recent call last):
  File "facility.py", line 25, in <module>
    import cplex
  File "/Users/sb/Applications/IBM/ILOG/CPLEX_Studio1251/cplex/python/x86_darwin/cplex/__init__.py", line 43, in <module>
    import callbacks
  File "/Users/sb/Applications/IBM/ILOG/CPLEX_Studio1251/cplex/python/x86_darwin/cplex/callbacks.py", line 48, in <module>
    from _internal._aux_functions import apply_freeform_two_args, apply_freeform_one_arg
  File "/Users/sb/Applications/IBM/ILOG/CPLEX_Studio1251/cplex/python/x86_darwin/cplex/_internal/__init__.py", line 22, in <module>
    import _list_array_utils
  File "/Users/sb/Applications/IBM/ILOG/CPLEX_Studio1251/cplex/python/x86_darwin/cplex/_internal/_list_array_utils.py", line 13, in <module>
    import _pycplex as CPX
  File "/Users/sb/Applications/IBM/ILOG/CPLEX_Studio1251/cplex/python/x86_darwin/cplex/_internal/_pycplex.py", line 19, in <module>
    _pycplex_platform = swig_import_helper()
  File "/Users/sb/Applications/IBM/ILOG/CPLEX_Studio1251/cplex/python/x86_darwin/cplex/_internal/_pycplex.py", line 15, in swig_import_helper
   _mod = imp.load_module('_pycplex_platform', fp, pathname, description)
  File "/Users/sb/Applications/IBM/ILOG/CPLEX_Studio1251/cplex/python/x86_darwin/cplex/_internal/_pycplex_platform.py", line 23, in <module>
   from cplex._internal.py1013_cplex1251 import *
  ImportError: dlopen(/Users/sb/Applications/IBM/ILOG/CPLEX_Studio1251/cplex/python/x86_darwin/cplex/_internal/py1013_cplex1251.so, 2): no suitable image found.  Did find:
    /Users/sb/Applications/IBM/ILOG/CPLEX_Studio1251/cplex/python/x86_darwin/cplex/_internal/py1013_cplex1251.so: mach-o, but wrong architecture

Unfortunately I am not familiar with the /.bash_profile but what is posted in the link I added at the end. Can please someone help me out here?

Upvotes: 0

Views: 604

Answers (1)

Felix
Felix

Reputation: 36

A possible solution to this would be to check whether you can copy the cplex directory manually over towards the site-packages that are installed (you may need to use sudo).

From your stacktrace I see that you have installed cplex into /Users/sb/Applications/IBM/ILOG/CPLEX_Studio1251/cplex/python/x86_darwin/

First run (I assume you python 2.7) in the interactive shell:

import site; site.getsitepackages() 

See How do I find the location of my Python site-packages directory? for details about this step.

This will give you the directory of the site-packages where you need to copy the "cplex" directory to. I assume it is /Library/Python/2.7/site-packages from here

on a mac then run:

sudo cp -r ./cplex /Library/Python/2.7/site-packages/

This sets up the cplex manually as an importable package for your python installation. You should therefore be able to import cplex within the python interactive shell.

Upvotes: 1

Related Questions