Decision Optimization

Decision Optimization

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

 View Only
  • 1.  ILOG CPLEX Teaching Edition-Python Problems- ImportError- 'import pycplex1'

    Posted Sat March 20, 2010 12:36 PM

    Originally posted by: pentunia


    I always end up with same error:
    'import pycplex121
    ImportError: DLL load failed: The specified module could not be found.'

    ILOG CPLEX Teaching Edition version 12.1, Windows XP SP3, Python version 2.6.4, Numpy
    I have rebooted and retried- same issues.
    I'm suppose to learn these tutorials, but I'm having the hardest time :/

    Sorry for the long post, I have tried so many things, spent soooo much time on this.
    Summary of what I have tried:

    INSTALL CPLEX ADD-INS FOR PYTHON:
    I have followed a number of manuals,docs post etc, for instance:
    C:\ILOG\CPLEX121tetrial\doc\ps_gscplex.pdf pg 236

    1. Added a New Environment / System variable:
    Variable name: PYTHONPATH
    Variable value: C:\ILOG\CPLEX121tetrial\python\x86_win32
    Have tried these values as well:
    C:\ILOG\CPLEX121tetrial\python\x86_win32\lib
    C:\ILOG\CPLEX121tetrial\python\x86_win32\lib\cplex

    2. Open a cmd prompt window and enter these cmds:
    cd C:\ILOG\CPLEX121tetrial\python\x86_win32
    python setup.py install
    running install
    running build
    running build_py
    creating build
    creating build\lib
    creating build\lib\cplex
    copying cplex\callbacks.py -> build\lib\cplex
    <snip>
    Writing C:\Python26\Lib\site-packages\cplex-12.1.0-py2.6.egg-info

    Reply no errors, seems fine?

    (I've also tried: python setup.py build --build-base=\ILOG\CPLEX121tetrial\python\x86_win32
    and reinstalling all soft, etc )

    3. Another doc said to, so I did:
    Copy C:\ILOG\CPLEX121tetrial\bin\x86_win32\cplex121.dll
    To: C:\ILOG\CPLEX121tetrial\examples\src\python\cplex121.dll

    4. (pg 237) Open a cmd prompt window, type in:
    python
    import cplex
    or
    from cplex import *
    or
    import cplex as NAME

    All give the same error:
    <snip>
    import pycplex121
    ImportError: DLL load failed: The specified module could not be found.
    5. Open a cmd prompt window and type in:
    cd C:\ILOG\CPLEX121tetrial\examples\src\python
    python
    execfile("diet.py")

    Reply: Always errors, for all .py files. Error msg's always end with:
    File "C:\ILOG\CPLEX121tetrial\python\x86_win32\cplex\_internal\_pycplex.py", line 5, in <module>
    import pycplex121
    ImportError: DLL load failed: The specified module could not be found.

    All same errors:
    execfile("lpex1.py")
    cpx.read("file.lp")
    cpx = cplex.Cplex("file.lp")

    Same errors if I use the Python command line and/or the Python IDLE (Python GUI)

    The only files I could find name pycplex121 is pycplex121.pyd
    google.com didn't find anything named pycplex121
    I do have: C:\Python26\Lib\site-packages\cplex\_internal\_pycplex.py
    when I try to run it, same error:
    C:\Python26\Lib\site-packages\cplex\_internal>python _pycplex.py
    Traceback (most recent call last):
    File "_pycplex.py", line 5, in <module>
    import pycplex121
    ImportError: DLL load failed: The specified module could not be found.

    6. I then tried using 'http://pycplex.googlecode.com/files/pycplex-2.0.zip'
    After setting that up I ended up with thee same errors :(

    7. I then try:
    Copying pycplex121.pyd C:\ILOG\CPLEX121tetrial\python\x86_win32
    Then in a cmd prompt window:
    python
    import cplex

    Reply: same errors:
    Traceback (most recent call last):
    File "<stdin>", line 1, in <module>
    File "cplex\__init__.py", line 149, in <module>
    import callbacks
    File "cplex\callbacks.py", line 47, in <module>
    from _internal._aux_functions import apply_freeform_two_args, apply_freeform_one_arg
    File "cplex\_internal\__init__.py", line 19, 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 5, in <module>
    import pycplex121
    ImportError: DLL load failed: The specified module could not be found.

    8. I then try:
    import sys
    sys.path.append("C:/ILOG/CPLEX121tetrial/python/x86_win32")
    sys.path.append("C:\ILOG\CPLEX121tetrial\python\x86_win32")
    import cplex

    Reply: Same error

    import pycplex121.pyd
    same error

    I then copy pycplex121.pyd to here:
    C:\Python26\DLLs\pycplex121.pyd

    Try again:
    import cplex

    Same error.
    Thank you for taking the time to read this mess :)
    #CPLEXOptimizers
    #DecisionOptimization


  • 2.  Re: ILOG CPLEX Teaching Edition-Python Problems- ImportError- 'import pycplex1'

    Posted Sat March 20, 2010 09:54 PM

    Originally posted by: SystemAdmin


    Hello,

    To use the Python API for CPLEX 12.1 on Windows, you must use Python version 2.5. An installer for this version of Python is available from the Python Software Foundation.

    Regards,

    Philip
    #CPLEXOptimizers
    #DecisionOptimization


  • 3.  Re: ILOG CPLEX Teaching Edition-Python Problems- ImportError- 'import pycplex1'

    Posted Sun March 21, 2010 09:54 PM

    Originally posted by: pentunia


    You're a star! :) Thank you Philip, that worked just perfect :)) Yay!
    thank you thank you thank you :D
    #CPLEXOptimizers
    #DecisionOptimization


  • 4.  Re: ILOG CPLEX Teaching Edition-Python Problems- ImportError- 'import pycplex1'

    Posted Mon May 17, 2010 03:04 AM

    Originally posted by: LJXue


    Does anybody know when python 2.6 will be officially supported?
    #CPLEXOptimizers
    #DecisionOptimization


  • 5.  Re: ILOG CPLEX Teaching Edition-Python Problems- ImportError- 'import pycplex1'

    Posted Mon May 17, 2010 02:05 PM

    Originally posted by: SystemAdmin


    Python 2.6 will be supported on Windows, Linux, and Mac OS with the next release of CPLEX, which will be available this quarter.

    Are there new features in Python 2.6 that you particularly want to use in combination with CPLEX?

    Philip Starhill
    CPLEX Research Engineer
    #CPLEXOptimizers
    #DecisionOptimization


  • 6.  Re: ILOG CPLEX Teaching Edition-Python Problems- ImportError- 'import pycplex1'

    Posted Tue May 18, 2010 04:38 PM

    Originally posted by: LJXue


    Hi, Philip, thank you very much for your answer.

    Not really. I just migrated from Matlab to Python recently, and all my environments are based on python 2.6, which prevented me from using cplex. Currently, I am using pycplex http://code.google.com/p/pycplex/ as a work around. However, I do hope to have official support of python 2.6.
    #CPLEXOptimizers
    #DecisionOptimization


  • 7.  Re: ILOG CPLEX Teaching Edition-Python Problems- ImportError- 'import pycplex1'

    Posted Sat November 28, 2015 06:05 PM

    Originally posted by: NellyMonserrat


    Hi everybody. 

    I've heard  that pypy is a fast, compilant alternative implementation of python languaje, since I have a model coding in python, I'm trying to use it, but I have problems linking it to cplex. Does anyone have idea of how do it? Cplex is already link with python, so, when I run the program with just python, everything is ok, but when I try to used pypy I get this error: ImportError: No module named cplex. the thing is that cplex is already in the path, look:

    >>>>sys.path

    ['', '/usr/lib/pypy/lib_pypy/__extensions__', '/usr/lib/pypy/lib_pypy', '/usr/lib/pypy/lib-python/2.7', '/usr/lib/pypy/lib-python/2.7/lib-tk', '/usr/lib/pypy/lib-python/2.7/plat-linux2', '/usr/local/lib/pypy2.7/dist-packages', '/usr/lib/pypy/dist-packages', '/usr/lib/pypy/dist-packages/cplex/lib/python/cplex']
     

    but when I am importing cplex, I get this message:

    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_cplex1251 import *
    ImportError: No module named cplex._internal.py1013_cplex1251

     

    Does anyone have idea of what's happening? Thanks in advantage 

     


    #CPLEXOptimizers
    #DecisionOptimization


  • 8.  Re: ILOG CPLEX Teaching Edition-Python Problems- ImportError- 'import pycplex1'

    Posted Sun November 29, 2015 11:29 AM

    Is this the same question as asked here?

    You should not ask the exact same question in multiple threads. And if you do that, then you should at least cross-reference the questions.


    #CPLEXOptimizers
    #DecisionOptimization