Decision Optimization

Expand all | Collapse all

CPLEX Python API Exception ignored in: AttributeError

  • 1.  CPLEX Python API Exception ignored in: AttributeError

    Posted 16 days ago

    Hello everyone,



    after running my model (succesfully) I get the following traceback:

    Exception ignored in: <function Cplex.__del__ at 0x00000171E25A08B0>

    Traceback (most recent call last):

    File "C:\Users\Ervin\Documents\Pyprojects\Inventory optimization\inv-opt\lib\site-packages\cplex\__init__.py", line 927, in __del__

    File "C:\Users\Ervin\Documents\Pyprojects\Inventory optimization\inv-opt\lib\site-packages\cplex\__init__.py", line 917, in end

    AttributeError: 'NoneType' object has no attribute 'freeprob'

    Exception ignored in: <function Environment.__del__ at 0x00000171E25649D0>

    Traceback (most recent call last):

    File "C:\Users\inv-opt\lib\site-packages\cplex\_internal\__init__.py", line 162, in __del__

    File "C:\\inv-opt\lib\site-packages\cplex\_internal\__init__.py", line 153, in _end

    File "C:\Users\Ervin\Documents\Pyprojects\Inventory optimization\inv-opt\lib\site-packages\cplex\_internal\__init__.py", line 245, in _delete_stream

    AttributeError: 'NoneType' object has no attribute 'getchannels'

    This leads me to believe this is some kind of bug as nowhere is my code is anything named 'getchannels' nor 'freeprob'. I am using pulp to compile the model and solve it through the python api.

    Has anyone encountered something similar?

    Kind regards



    ------------------------------
    John Smith
    ------------------------------


  • 2.  RE: CPLEX Python API Exception ignored in: AttributeError

    Posted 16 days ago
    Hi,

    The error you see makes me think that somehow, cplex has not been installed correctly (It could not import `.procedural` which is a subpackage of `cplex`.
    It also looks like you have multiple versions of Cplex installed in multiple places.
    C:\Users\inv-opt\lib\site-packages\cplex
    - C:\\inv-opt\lib\site-packages\cplex  (unless this is a cut past problem and same as above)
    - C:\Users\Ervin\Documents\Pyprojects\Inventory optimization\inv-opt\lib\site-packages\cplex

    This should be ok since cplex does relative imports.
    However, you might have different versions. Can we check the CPLEX versions in those locations ? You can get the version by opening the "__init__.py"  file under the different `cplex` directories, and the versions is near the begining of the page, like:

    ```
    __version__ = "20.1.0.0"
    ```



    ------------------------------
    Viu Long Kong
    ------------------------------



  • 3.  RE: CPLEX Python API Exception ignored in: AttributeError

    Posted 15 days ago

    Dear Viu,

    the cplex python api has been installed only in one location, the path differ because of some error during copy-pasting.

    Checking the __innit__ version 20.1.0.0 is indeed installed.

    Do have however 2 version of cplex optimization studio installed, I do not know if that would be relevant?

    Kind regards



    ------------------------------
    John Smith
    ------------------------------



  • 4.  RE: CPLEX Python API Exception ignored in: AttributeError

    Posted 14 days ago
    No it's ok to have multiple versions of cplex optimization studio installed, as long as you take care of installing the python wrappers in different virtual envs.
    From your stack trace, it looks like cplex could not import its internal package `procedural` - I'd like us to check that the install is good here.
    Can you please run this in your python environment:

    ``
    import cplex._internal._procedural as proc
    print(proc.__file__)
    ``




    ------------------------------
    Viu Long Kong
    ------------------------------



  • 5.  RE: CPLEX Python API Exception ignored in: AttributeError

    Posted 13 days ago

    thank you for your help.

    The command seems to run fine, this is the output:
    C:\Users\Ervin\Documents\Pyprojects\Inventory optimization\inv-opt\lib\site-packages\cplex\_internal\_procedural.py



    ------------------------------
    John Smith
    ------------------------------



  • 6.  RE: CPLEX Python API Exception ignored in: AttributeError

    Posted 13 days ago
    So  this looks like cplex was installed correctly.

    This is not an error we have already seen, at least to my knowledge.
    Would you mind sending me a sample that would reproduce this so that I can see if this is a problem on our side or on pulp's side ?
    (as a private message - or as email viulong.kong@fr.ibm.com )

    ------------------------------
    Viu Long Kong
    ------------------------------