0

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?

rkersh
  • 4,447
  • 2
  • 22
  • 31
steph
  • 555
  • 2
  • 6
  • 21
  • There are some things that are wrong in that blog. For example, after you run setup.py there is no reason to set PYTHONPATH (well, if you don't use --home). Finally, is there some reason why you can't use the latest version of CPLEX (currently 12.6.3)? If you're on the academic initiative it is free and in more recent versions of CPLEX, for example, you don't have to worry about the 32-bit issue either. – rkersh May 18 '16 at 21:58
  • Also, it could be that your version of OSX is too new (i.e., isn't supported from 12.5.1). You'll have to read the [detailed system requirements](http://www-01.ibm.com/support/docview.wss?uid=swg27019100) (unfortunately this page appears to be broken at the moment). :-( – rkersh May 18 '16 at 22:10
  • Unfortunately that is the only version I got for the project ... So there is no way to make it work? – steph May 19 '16 at 06:31
  • I'm not familiar with OSX, is it possible to install 32-bit libraries on 64-bit OSX? You might need ones to call CPLEX. Plus, does your cplex have problems with python only? did you try to compile cpp or java cplex example files or call cplex interactive shell? – serge_k May 19 '16 at 08:36
  • I tried cpp and it worked. So I guess it is only with Python – steph May 19 '16 at 11:54
  • The link I mentioned in the previous comment is working again. 12.5.1 is supported on OSX 10.6 and 10.7. What version do you have? If you're not eligible for the [Academic Initiative](http://www-304.ibm.com/ibm/university/academic/pub/page/mem_join) you can try the [Community Edition](https://www-01.ibm.com/software/websphere/products/optimization/cplex-studio-community-edition/). Good luck. – rkersh May 19 '16 at 18:05

1 Answers1

1

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.

Community
  • 1
  • 1
Felix
  • 36
  • 5