Skip to main content

Gurobi with python version 3.8

Answered

Comments

10 comments

  • Matthias Miltenberger
    Gurobi Staff Gurobi Staff

    True, there is no conda package for Python 3.8. Keep in mind that when installing Anaconda, Python 3.7 is still the default Python version. Apart from that, you can install Gurobi in Python 3.8 via

    python setup.py install

    executed from the Gurobi home directory.

    Cheers,
    Matthias

    1
  • Robert Hildebrand
    Gurobi-versary
    Conversationalist
    First Question

    If you're on a windows computer, you need to execute the setup.py file using the python located in your anaconda distribution.

     

    Here are my instructions for installing gurobi/anaconda:

     

    Installing Anaconda and Gurobi

     

    How to install GUROBI and Anaconda on a Windows Computer

    1. [Register GUROBI account]  Go to https://www.gurobi.com/registration/general-reg (Links to an external site.) to create and account.  Use your UNO email address.
    2. [Download GUROBI]  Go to https://www.gurobi.com/downloads/download-center (Links to an external site.) and follow the instructions under "Download the Latest Version of Gurobi".  You want the Gurobi Optimizer (note that you need to log in first). At some point you'll choose the version for your computer (windows, mac, linux).
    3. [Install GUROBI]. Install the Gurobi Optimizer.
    4. [Acquire GUROBI Academic License]  Go to https://user.gurobi.com/download/licenses/free-academic (Links to an external site.) and request an Academic license for Gurobi.  Once you request a license, find the license key that should look like:  grbgetkey ca4c8b84-630r-11ea-q568-0a7c4f31bafe.
    5. [Add the license to GUROBI].  From your start menu, search for GUROBI and open the application.  A terminal should open up and ask you for the license.   Copy and paste your license: ca4c8b84-630r-11ea-q568-0a7c4f31bafe and hit enter.
    6. [Download Anaconda].  Go to https://www.anaconda.com/products/individual (Links to an external site.) and find your proper version to install at the bottom of the page.  Probably 64-bit graphical installer.
    7. [Install Anaconda]  Run the download and install Anaconda

    Now we need to connect GUROBI to Anaconda.

    Option #1:   

    1. [Open Anaconda Prompt].  Go to your start menu and search for "Anaconda Prompt".  Open that.  An Anaconda terminal window will open.
    2. [Downgrade Anaconda to Python 3.7].  In the terminal, type 
      conda install python=3.7
       and hit enter.
    3. [Connect GUROBI to Anaconda]  From an Anaconda terminal issue the following command to add the Gurobi channel to your default search list:

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

      Now issue the following command to install the Gurobi package:

      conda install gurobi

    You should be good to go! 

    Option #2:   

    1. [Find folder] Search in windows file explorer for a file "gurobi903"
    2. [Retrieve Path to Folder] Within this folder, right-click on "win64" and ask to get info on the folder.  Copy the path to this folder.  If should be something like "C:gurobi903\win64\".  Store this for later.
    3. [Find python in Anaconda] Again in your file explorer,  search for Anaconda.  We need to find the Python executable that is under the Anaconda folder.  This should be at a path like: "C:\users\USERNAME\anaconda3\Python" where USERNAME is probably your name.  Copy that path and save it for later.
    4. [Open command line prompt] From your start menu, click "run".  A little box should open with "cmd" as the commend.   Click "Ok".   Now a terminal should open for you.
    5. [Change file directory] In the terminal, run the command
       cd C:gurobi903\win64\ 
    6. [Run setup.py] In the terminal, run the command  
      C:\users\USERNAME\anaconda3\Python setup.py install

    You should be good to go!

     

     

    How to install GUROBI and Anaconda on a Mac

    1. [Register GUROBI account]  Go to https://www.gurobi.com/registration/general-reg (Links to an external site.) to create and account.  Use your UNO email address.
    2. [Download GUROBI]  Go to https://www.gurobi.com/downloads/download-center (Links to an external site.) and follow the instructions under "Download the Latest Version of Gurobi".  You want the Gurobi Optimizer (note that you need to log in first). At some point you'll choose the version for your computer (windows, mac, linux).
    3. [Install GUROBI]. Install the Gurobi Optimizer.
    4. [Acquire GUROBI Academic License]  Go to https://user.gurobi.com/download/licenses/free-academic (Links to an external site.) and request an Academic license for Gurobi.  Once you request a license, find the license key that should look like:  grbgetkey ca4c8b84-630r-11ea-q568-0a7c4f31bafe.
    5. [Add the license to GUROBI]. In your finder, search for a folder "gurobi903".   Then navigate info the subfolder "mac64" and into the subfolder "bin".  Double click on the file "grbgetkey".  This should open a terminal asking for your license.  Copy and paste your license: ca4c8b84-630r-11ea-q568-0a7c4f31bafe and hit enter.
    6. [Download Anaconda].  Go to https://www.anaconda.com/products/individual (Links to an external site.) and find your proper version to install at the bottom of the page.  Probably 64-bit graphical installer.
    7. [Install Anaconda]  Run the download and install Anaconda

    Now we need to connect GUROBI to Anaconda.

    1. [Find folder] Search in the finder for a file "gurobi903"
    2. [Retrieve Path to Folder] Within this folder, right-click on "mac64" and ask to get info on the folder.  Copy the path to this folder.  If should be something like " /Library/gurobi903/mac64"
    3. [Open a terminal] From the launchpad, search for "terminal" and open the terminal.
    4. [Change file directory] In the terminal, run the command
       cd /Library/gurobi903/mac64 
    5. [Run setup.py] In the terminal, run the command  
      python setup.py install

    You should be good to go!

    1
  • Vinh Ngo
    Gurobi-versary
    First Comment

    I also have the same problem with the exact same message. Following. 

    0
  • Marc Port
    Gurobi-versary
    First Comment

    I can also report that although Gurobi 9 advertises that it has Python 3.8 support there is no conda package that supports latest 3.8. And python 3.8 is not so young it is already in 3.8.3 version...

    0
  • sahar Jolini
    Gurobi-versary
    First Comment

    I write this command python setup.py install on my shell but there is an error that says there is no such file or directory. what should I do?

    0
  • Matthias Miltenberger
    Gurobi Staff Gurobi Staff

    You need to run this command from within the Gurobi installation directory.

    Cheers,
    Matthias

    0
  • Natalie Crow
    Gurobi-versary
    First Comment

    I have Python 3.8 as well and have executed the setup.py install from the Gurobi directory. It still does not recognize gurobipy in Jupyter. Should I downgrade to Python 3.7 for it to load in Jupyter?

    0
  • Natalie Crow
    Gurobi-versary
    First Comment

    I did downgrade and it did end up working.

    0
  • Sabreen Rashwan
    Gurobi-versary
    First Comment

    I have got the same incompatibility issue. I uninstalled Anaconda and tried to remove its directories. Uninstalled Gurobi (academic license) and redid the work again. When I asked Anaconda to install python 3.7, it started to downgrade other packages ( I thought no problem doing so and I gave it the permission). The problem is when I   tried to copy my academic license key I got a syntax error. I can see two licenses in my account and tried the two keys with no vain. 

    I used the Run command to write the key and it worked but told me that my key license is in a different folder other than the default. 

    I manually cut and paste the license file from that location to the gurobi default folder. Now I have the current situation as shown in the image. But when I tried to run a code in spyder I got a message telling me no gurobi module is there.

    What I should do now?

    0
  • Christoph Deil
    Gurobi-versary
    First Comment

    Could you please release Gurobi conda packages for Python 3.8?

    That would be very nice to have the simple install.

    Note that Anaconda now ships 3.8, so more and more users will have that.

    0

Please sign in to leave a comment.