Failed to import gurobipy
AnsweredAs the picture is shown upward. Even I've reinstalled gurobi or anaconda, there is still an error. Does anyone know how to solve this problem?
My gurobi version is 9.1.0 and Python is 3.8.3.
Thx.
-
Official comment
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ł -
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 -
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 -
Hi Jaromił,
Thanks for your help, now I've succeeded to import gurobipy. Really appreciate.
Sincerely,
Chien-Hao Huang
0 -
Thank you very much Jaromil! It works for me too now!
0
Please sign in to leave a comment.
Comments
5 comments