Error on Pycharm

Comments

5 comments

  • Silke Horn

    Could you give us some additional information:

    • How exactly did you install the Gurobi Python package? Did you use conda ("conda install gurobi") or did you install it using setup.py (e.g. "python setup.py install")?
    • Where do you get this error? Do you only get it in PyCharm or also using the interactive shell?
    0
    Comment actions Permalink
  • Basem Alkhaleel
    • I used python setup.py install
    • I get the error using the python console inside Pycharm; however, if I run the file through a Jupyter notebook or through "Run" command in Pycharm I don't get the error. My python environment is managed through anaconda.
    0
    Comment actions Permalink
  • Jeff Burnett

    I had a similar error, but only when I was in debug mode in pycharm. In my case, gurobi is installed on linux. I have run many of the python examples successfully provided I don't try to set breakpoints.

     

    Connected to pydev debugger (build 193.6494.30)
    Using license file /home/jeff/local/gurobi/gurobi.lic
    Traceback (most recent call last):
    File "/mnt/b06cb29c-6a92-4382-ad49-9dd8e02b4c7e/home/jeff/.pycharm_helpers/pydev/_pydevd_bundle/pydevd_xml.py", line 282, in frame_vars_to_xml
    xml += var_to_xml(v, str(k), evaluate_full_value=eval_full_val)
    File "/mnt/b06cb29c-6a92-4382-ad49-9dd8e02b4c7e/home/jeff/.pycharm_helpers/pydev/_pydevd_bundle/pydevd_xml.py", line 369, in var_to_xml
    elif hasattr(v, "__len__") and not is_string(v):
    File "model.pxi", line 342, in gurobipy.Model.__getattr__
    KeyError: '__len__'
    Unexpected error, recovered safely.

    0
    Comment actions Permalink
  • Eli Towle

    Hi,

    This behavior will be fixed in the next bugfix release of Gurobi. Thanks for letting us know about it!

    In the meantime, a possible workaround is to explicitly set the __len__ attribute of the Model object. E.g.:

    model.__len__ = 1

    Eli

    0
    Comment actions Permalink
  • Jeff Burnett

    That fixed it for me. Thanks for the quick response. 

    Jeff

    0
    Comment actions Permalink

Please sign in to leave a comment.

Powered by Zendesk