Decision Optimization

Decision Optimization

Delivers prescriptive analytics capabilities and decision intelligence to improve decision-making.

 View Only
  • 1.  python module importerror

    Posted Fri February 03, 2012 02:38 PM

    Originally posted by: BrendanTracey


    Hi, I am having trouble getting the python cplex module to import.

    I am running windows 7 professional, have the academic studio 12.3, and am using python 2.6 . I have tried the recommended method (shown below) both of adding the cplex directory to the python path as well as creating a PYTHONPATH

    running the code:
    str='C:\\Program Files\\IBM\\ILOG\\CPLEX_Studio_Academic123\\cplex\\python\\x64_win64'
    sys.path.append(str)
    import cplex
    Gives the following slew of errors:

    Traceback (most recent call last):
    File "test.py", line 14, in <module>
    import cplex
    File "C:\Program Files\IBM\ILOG\CPLEX_Studio_Academic123\cplex\python\x64_win64\cplex\__init__.py", line 43, in <module>
    import callbacks
    File "C:\Program Files\IBM\ILOG\CPLEX_Studio_Academic123\cplex\python\x64_win64\cplex\callbacks.py", line 48, in <module>
    from _internal._aux_functions import apply_freeform_two_args, apply_freeform_one_arg
    File "C:\Program Files\IBM\ILOG\CPLEX_Studio_Academic123\cplex\python\x64_win64\cplex\_internal\__init__.py", line 22, in <module>
    import _list_array_utils
    File "C:\Program Files\IBM\ILOG\CPLEX_Studio_Academic123\cplex\python\x64_win64\cplex\_internal\_list_array_utils.py", line 13, in <module>
    import _pycplex as CPX
    File "C:\Program Files\IBM\ILOG\CPLEX_Studio_Academic123\cplex\python\x64_win64\cplex\_internal\_pycplex.py", line 25, in <module>
    _pycplex_platform = swig_import_helper()
    File "C:\Program Files\IBM\ILOG\CPLEX_Studio_Academic123\cplex\python\x64_win64\cplex\_internal\_pycplex.py", line 21, in swig_import_helper
    _mod = imp.load_module('_pycplex_platform', fp, pathname, description)
    File "C:\Program Files\IBM\ILOG\CPLEX_Studio_Academic123\cplex\python\x64_win64\cplex\_internal\_pycplex_platform.py", line 28, in <module>
    from cplex._internal.py26_cplex123 import *
    ImportError: DLL load failed: %1 is not a valid Win32 application.
    #CPLEXOptimizers
    #DecisionOptimization


  • 2.  Re: python module importerror

    Posted Fri February 03, 2012 02:41 PM

    Originally posted by: BrendanTracey


    Sorry, it somehow hit 'post' on me. I have tried adding it directly to the python path, I have tried creating a pythonpath variable, and I have also tried using the python 'install' command that was recommended here to install it to the python Lib\site-packages directory. I'm not sure what else I should try or what the error means specifically.

    Thank you
    #CPLEXOptimizers
    #DecisionOptimization


  • 3.  Re: python module importerror

    Posted Mon February 06, 2012 02:18 AM

    Originally posted by: SystemAdmin


    I vaguely remember this error message. Did you search the Forum for that?
    I am not a Python expert but if I remember correctly then the problem was that a 64bit Python was trying to use a 32bit CPLEX library, or vice versa. In your case it seems like a 32bit Python is trying to use a 64bit library? Does it work if you use the 32bit CPLEX library instead? Or a 64bit Python?
    #CPLEXOptimizers
    #DecisionOptimization


  • 4.  Re: python module importerror

    Posted Mon February 06, 2012 07:25 PM

    Originally posted by: BrendanTracey


    That appears to have worked. the "import cplex" line seems to not give an error now. Thanks!

    (I say appear because now I need to figure out how to get the license file working...)
    #CPLEXOptimizers
    #DecisionOptimization