Skip to main content

Install Gurobi into Anaconda

Ongoing

Comments

8 comments

  • Jaromił Najman
    Gurobi Staff Gurobi Staff

    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
  • Wl MK
    Conversationalist
    First Question

    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
  • Gwyneth Butera
    Gurobi Staff Gurobi Staff

    It seems that something in your conda environment is not quite right. 

    Can you

    1. remove the gurobi package with conda remove gurobi?
    2. 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.
    3. let us know where you are calling "import gurobipy" (from Jupyter, an IDE, etc.)?
    4. Send us the output of running conda info from the command line?

    0
  • Zed Dean
    Gurobi Staff Gurobi Staff

    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 -y

     

     

    0
  • Wl MK
    Conversationalist
    First Question

    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
  • Zed Dean
    Gurobi Staff Gurobi Staff

    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
    - defaults

    I hope that will help.

    0
  • Wl MK
    Conversationalist
    First Question

    Zed Dean here is what I got:

    channels:
      - https://conda.anaconda.org/gurobi
      - http://conda.anaconda.org/gurobi
      - defaults
    0
  • Zed Dean
    Gurobi Staff Gurobi Staff

    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  gurobi

    The 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.