Gurobi uses environment variables for multiple configuration purposes. For example, you can set the variable GRB_LICENSE_FILE to indicate where to look for a license file, or set environment variables required for installation on Linux distributions. Please find below the instructions that are relevant to your operating system.
Windows
On Windows systems, environment variables are created and modified through the Control Panel. Searching for Environment Variables from the Control Panel search box will lead you to the appropriate screen. You will need to add a new System variable named GRB_LICENSE_FILE, and set it to the location of your license file (e.g., C:\gurobi\gurobi.lic). Important note: if your new environment variable is a User variable, this setting will only work for the current user.
Linux
The method for setting environment variables in Linux is dependent on the shell you are using. If you are using Bash then you can set an environment variable by adding a line to your .bashrc file. For example, to set the GRB_LICENSE_FILE variable to the location of your license file:
export GRB_LICENSE_FILE=/usr/home/jones/gurobi.lic
For csh shell users, you should add the following to your .cshrc file:
setenv GRB_LICENSE_FILE /usr/home/jones/gurobi.lic
For zsh users, the format is the same as Bash, however the settings should be added to your .zshenv file.
Environment variables required for installation on Linux
You will also need to create or modify the following environment variables when installing Gurobi on Linux:
- GUROBI_HOME should point to your <installdir>.
- PATH should be extended to include <installdir>/bin.
- LD_LIBRARY_PATH should be extended to include <installdir>/lib.
Users of the bash shell should add the following lines to their .bashrc files:
export GUROBI_HOME="/opt/gurobi1103/linux64"
export PATH="${PATH}:${GUROBI_HOME}/bin"
export LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:${GUROBI_HOME}/lib"
Users of the csh shell should add the following lines to their .cshrc files:
setenv GUROBI_HOME /opt/gurobi1103/linux64
setenv PATH ${PATH}:${GUROBI_HOME}/bin
setenv LD_LIBRARY_PATH ${LD_LIBRARY_PATH}:${GUROBI_HOME}/lib
If LD_LIBRARY_PATH is not already set, use the following instead:
export LD_LIBRARY_PATH="${GUROBI_HOME}/lib"
or
setenv LD_LIBRARY_PATH ${GUROBI_HOME}/libThese paths should be adjusted to reflect your chosen <installdir>. In case you are installing the ARM build, the paths need to be adjusted to armlinux64.
Launching from the desktop?
In some Linux distributions, applications launched from the Linux desktop won't read .bashrc (or .cshrc). You may need to set the Gurobi environment variables in .bash_profile or .profile instead. Unfortunately, the details of where to set these variables vary widely among different Linux distributions. We suggest that you consult the documentation for your distribution if you run into trouble.
macOS
You can set an environment variable by adding a line to your shell startup file (.zshenv for zsh, .bash_profile for bash):
export GRB_LICENSE_FILE=/Users/jones/gurobi.lic
Note that once you have modified environment variables you will likely need to close any open terminal windows and open a new one after you have made changes for them to take effect.
Comments
0 comments
Article is closed for comments.