Skip to main content

Gurobipy is installed in my environment but cannot be found on my jupyter notebook

Answered

Comments

6 comments

  • Lennart Lahrs
    Gurobi Staff Gurobi Staff

    Hi Kim,

    To solve your problem, please try the following:

    • make sure your environment is active,
    • call pip uninstall gurobipy, or create a new environment,
    • move to the directory of your Gurobi installation, which seems to be <user_path>/opt/gurobi1001/linux64 in your case,
    • call python setup.py install. (Note that the order is different from what you tried above.)

    Please let me know if this did not solve the issue.

    Regarding your initial attempt, calling pip install -e <directory> creates a symbolic link to a directory, assuming that there is complete Python source code for a PIP project at that location, which is not the case here. This is a useful feature if you were actively developing the code at that location.

    Best regards,
    Lennart

    0
  • Kim Nicoli
    Gurobi-versary
    First Question
    First Comment

    Hi Lennart, 
    First and foremost, thanks a lot for your quick reply. 

    First, I apologize for mistyping the command above python setup.py install in my message. 
    Also thanks for clarifying that the symbolic linking would not work in this case. 

    I tried what you suggested and I got this message. 

    /homes/knicoli/env/lib/python3.8/site-packages/setuptools/dist.py:173: SetuptoolsDeprecationWarning: Invalid config.
    !!

            ********************************************************************************
            newlines are not allowed in `summary` and will break in the future
            ********************************************************************************

    !!
      write_field('Summary', single_line(summary))
    removing /homes/knicoli/opt/gurobi1001/linux64/build

     

    It does not seem to have worked because when I try to import gurobipy in the Jupyter notebook I get 

    ---------------------------------------------------------------------------
    ImportError                               Traceback (most recent call last)
    Cell In[3], line 13
    ---> 13 from gurobi_samplers import gurobi_optimization
    
    File ~/project/gurobi_samplers.py:2
          1 import numpy as np
    ----> 2 import gurobipy as gp
          3 from gurobipy import GRB
          5 def gurobi_optimization(
          6     Q: np.ndarray):
    
    File ~/env/lib/python3.8/site-packages/gurobipy/__init__.py:1
    ----> 1 from .gurobipy import *
    
    ImportError: libgurobi100.so: cannot open shared object file: No such file or directory

     

    Any further suggestion?

    0
  • Lennart Lahrs
    Gurobi Staff Gurobi Staff

    Hi Kim,

    Can you please try the below command, from within your active environment? This installs the gurobipy extension from the public PyPI server.

    python -m pip install gurobipy

    Best regards,
    Lennart

    0
  • Kim Nicoli
    Gurobi-versary
    First Question
    First Comment

    Hi Lennart, 

    Thanks a lot for your reply. 
    I did what you suggested. That indeed now finds gurobipy and allows me to import the library. 

    However, I now get the complaint my license cannot be found and get the following error:

    GurobiError: Unable to open Gurobi license file '~/gurobi.lic'

    Any suggestions on how to resolve this? 
    The workflow I followed is the following. 

    1. I ran grbgetkey <my_key> inside the environment

    2. I moved the gurobi.lic file to /homes/knicoli/opt/gurobi1001 and set export GRB_LICENSE_FILE="~/opt/gurobi1001/gurobi.lic"

     

    Am I doing something wrong, or shall I do this differently?

    0
  • Lennart Lahrs
    Gurobi Staff Gurobi Staff

    Hi Kim,

    We recommend placing the license file in one of the following directories:
    /opt/gurobi, /opt/gurobi1001 (for 10.0.1), or your home directory.

    If you place your license file in one of those directories, you do not need to set the GRB_LICENSE_FILE environment variable, so I recommend moving the file to one of the above paths.

    If you prefer a non-default location, using "~" to refer to your home directory in the export call will not work. You can use export GRB_LICENSE_FILE="$HOME/opt/gurobi1001/gurobi.lic" instead. You can check your HOME environment variable using echo $HOME and see whether the output matches your expected path prefix.

    0
  • Kim Nicoli
    Gurobi-versary
    First Question
    First Comment

    Hi Lennart, 

    Wonderful, that worked! 
    Thank you so much for your quick and friendly support. 

    Best wishes, 
    Kim

    0

Please sign in to leave a comment.