Install Gurobi into Anaconda
OngoingHi,
I have installed a Gurobi (9.5.0) license, and when I want to Install Gurobi into Anaconda I faced this issue:
(base) C:\Users\Hp>conda install gurobi
Collecting package metadata (current_repodata.json): done
Solving environment: failed with initial frozen solve. Retrying with flexible solve.
Solving environment: failed with repodata from current_repodata.json, will retry with next repodata source.
Collecting package metadata (repodata.json): done
Solving environment: failed with initial frozen solve. Retrying with flexible solve.
Solving environment: \
Found conflicts! Looking for incompatible packages.
This can take several minutes. Press CTRL-C to abort.
Examining gurobi: 50%|█████████████████████████████████ | 2/4 [00:00<00:00, 4.98it/s]/failed
UnsatisfiableError: The following specifications were found
to be incompatible with the existing python installation in your environment:
Specifications:
- gurobi -> python[version='2.7.*|3.5.*|>=2.7,<2.8.0a0|>=3.6,<3.7.0a0']
Your python: python=3.9
If python is on the left-most side of the chain, that's the version you've asked for.
When python appears to the right, that indicates that the thing on the left is somehow
not available for the python version you are constrained to. Note that conda will not
change your python version to a different minor version unless you explicitly specify
that.
I tried also with python setup.py install but when I try to import gurobipy I get this error:
--------------------------------------------------------------------------- ImportError Traceback (most recent call last) ~\AppData\Local\Temp/ipykernel_9420/2174118868.py in <module> ----> 1 from gurobipy import * ~\Anaconda3\lib\site-packages\gurobipy\__init__.py in <module> 2 if hasattr(os, 'add_dll_directory'): 3 os.add_dll_directory(os.path.join(os.getenv('GUROBI_HOME'),'bin')) ----> 4 from .gurobipy import * ImportError: DLL load failed while importing gurobipy: %1 n’est pas une application Win32 valide.
How can I solve this issue?
And thank you.
-
To install Gurobi using Anaconda/ Miniconda you may do the following:
Make sure to add the gurobi channel before you attempt to install it.
Create an env with python 3.8, then use this environment for gurobi.
As suggested below:
conda config --add channels https://conda.anaconda.org/gurobi
conda create --name gurobi950 python python=3.8.11 numpy scipy -y
conda activate gurobi950
conda install -c gurobi gurobi=9.5.0 -y1 -
Hi,
Gurobi 9.5.0 does indeed support Python 3.9 but this version is not available via conda. Our Anaconda distribution currently only provides support for Python 3.7 and 3.8.
You can either install Gurobi on Python 3.9 by using pip:python -m pip install gurobipy
or by using the installer included in the installation package:
python setup.py install
It seems like you are trying to install Gurobi on a Win32 machine. Please note that Win32 is not supported. Do you have the possibility to change to a different machine?
Best regards,
Jaromił0 -
Thank you,
I tried with both
python -m pip install gurobipy
and
python setup.py install
but always getting:
--------------------------------------------------------------------------- ImportError Traceback (most recent call last) ~\AppData\Local\Temp/ipykernel_7188/621058730.py in <module> ----> 1 import gurobipy as gp ~\Anaconda3\lib\site-packages\gurobipy\__init__.py in <module> 2 if hasattr(os, 'add_dll_directory'): 3 os.add_dll_directory(os.path.join(os.getenv('GUROBI_HOME'),'bin')) ----> 4 from .gurobipy import * ImportError: DLL load failed while importing gurobipy: %1 n’est pas une application Win32 valide.
I am working with a 64-bit operating system, x64 processor. I'm not sure why win32 is there.0 -
It seems that something in your conda environment is not quite right.
Can you
- remove the
gurobi
package withconda remove gurobi?
- download and install the full Gurobi package as described in How do I install Gurobi for Python? Please be sure the python you use for the setup command is the same one as the one in the conda environment you want to use.
- let us know where you are calling "import gurobipy" (from Jupyter, an IDE, etc.)?
- Send us the output of running conda info from the command line?
0 - remove the
-
Hi Zed Dean, I did exactly what you suggested, but I'm getting this:
(my_gurobi950) C:\Users\Hp>conda install -c gurobi gurobi=9.5.0 -y
Collecting package metadata (current_repodata.json): done
Solving environment: failed with initial frozen solve. Retrying with flexible solve.
Collecting package metadata (repodata.json): done
Solving environment: failed with initial frozen solve. Retrying with flexible solve.
PackagesNotFoundError: The following packages are not available from current channels:
- gurobi=9.5.0
Current channels:
- https://conda.anaconda.org/gurobi/win-32
- https://conda.anaconda.org/gurobi/noarch
- http://conda.anaconda.org/gurobi/win-32
- http://conda.anaconda.org/gurobi/noarch
- https://repo.anaconda.com/pkgs/main/win-32
- https://repo.anaconda.com/pkgs/main/noarch
- https://repo.anaconda.com/pkgs/r/win-32
- https://repo.anaconda.com/pkgs/r/noarch
- https://repo.anaconda.com/pkgs/msys2/win-32
- https://repo.anaconda.com/pkgs/msys2/noarch
To search for alternate channels that may provide the conda package you're
looking for, navigate to
https://anaconda.org
and use the search bar at the top of the page.Should I install additional packages?
0 -
Hello WI,
The reply you got suggests that the Gurobi channel was not added appropriately.
Could you please ensure that the following command line was run successfully? please avoid specifying any sublocation with the channel.
conda config --add channels https://conda.anaconda.org/gurobi
To verify the channel was added correctly, you may run the following command:
conda config --show channels
The expected output should look like the following
channels:
- https://conda.anaconda.org/gurobi
- conda-forge
- defaultsI hope that will help.
0 -
Zed Dean here is what I got:
channels:
- https://conda.anaconda.org/gurobi
- http://conda.anaconda.org/gurobi
- defaults0 -
Hello WI,
Your channels do not seem to get updated automatically, as they should be.
Please make sure to keep your Conda up to date.
Try to run this command line:
conda search --override-channels --channel https://conda.anaconda.org/gurobi gurobi
This will show all the gurobi packages available to you and you should see 9.5.0 at the end of the list. If you can not see it, you need to make sure the channels are updated.
You should expect an output like below:
gurobi 9.1.2 py36_0 gurobi
gurobi 9.1.2 py37_0 gurobi
gurobi 9.1.2 py38_0 gurobi
gurobi 9.5.0 py27_0 gurobi
gurobi 9.5.0 py37_0 gurobi
gurobi 9.5.0 py38_0 gurobiThe list will show you that 9.5.0 is available to only three python packages 2.7,3.7 and 3.8
I hope that will help,
Yours,
Zed
0
Please sign in to leave a comment.
Comments
8 comments