Skip to main content

Failed to import gurobipy

Answered

Comments

5 comments

  • Official comment
    Jaromił Najman
    Gurobi Staff Gurobi Staff

    Hi,

    First, you have to download the Gurobi Optimization Software from our website and install it, see the Software Installation Guide.

    Next, you open a terminal window. On Windows 10 you can achieve that by pressing the windows button, then typing \(\texttt{cmd}\) and hitting Enter. A terminal window should be opened. There, you navigate to you Gurobi installation folder via

    cd C:\gurobi910\win64

    This only works, if you installed Gurobi in its default location.

    Finally, you execute the command

    python setup.py install

    For more details, please have a look at our documentation on Manual installation for Python.

    Best regards,
    Jaromił

  • Jaromił Najman
    Gurobi Staff Gurobi Staff

    Hi,

    It seems like your environment variable \(\texttt{GUROBI_HOME}\) has no value. Therefore, the \(\texttt{os.getenv()}\) method returns a \(\texttt{None}\) object.

    Did you install the Gurobi 9.1 optimizer software? Just downloading it via pip or anaconda may not be enough, because pip or anaconda may not have the rights to set environment variables.

    How did you install Gurobi into your Python distribution?

    Could you try executing the command \(\texttt{python setup.py install}\) from inside your Gurobi installation folder, i.e., \(\texttt{<pathToGurobi>/gurobi910/win64}\)?

    Did you have a look at our Knowledge Base article How do I install Gurobi for Python?

    Best regards,
    Jaromił

    0
  • Chien-Hao Huang
    Gurobi-versary
    First Comment
    First Question

    Hi,

    Here are the following steps for me to install Gurobi, and I use an Anaconda prompt:

    Step 1: Add the Gurobi channel to your default search list:

    conda config --add channels http://conda.anaconda.org/gurobi

    Step 2: Install the Gurobi package:

    conda install gurobi

    Step 3: Install the license. Copy and paste

    grbgetkey xxxxxx-xxxxxx

    command to the terminal / prompt. 

     

    Could you mind tell more detail about executing the command

    python setup.py install 

    from inside the Gurobi installation folder? I could not understand what you mean.

    Thx.

    0
  • Chien-Hao Huang
    Gurobi-versary
    First Comment
    First Question

    Hi Jaromił, 

    Thanks for your help, now I've succeeded to import gurobipy. Really appreciate.

     

    Sincerely, 

    Chien-Hao Huang

     

    0
  • Vanja Zomer
    Gurobi-versary
    First Comment
    First Question

    Thank you very much Jaromil! It works for me too now!

    0

Please sign in to leave a comment.