installing gurobi in python requires root access
AnsweredInstalling Gurobi with the python anaconda package manager is easy and does not require root access. A regular user can simply create a new virtual environment and install the gurobi package:
> conda create --name gurobi-env gurobi
However, how can a regular user use gurobi with a different package manager? Gurobi is installed in /opt/gurobi to make it system-wide available. Regular (non-root) users can read and execute the various gurobi scripts. Similar to the Anaconda example, a user would typically spawn a virtual python environment, and install gurobi locally. To this extend, gurobi provides a setup.py script.
1. spawn the virtual environment:
> python3 -m venv gurobi-env
2. install gurobi (needs to be executed from within the gurobi directory)
> python setup.py install
The last command will throw an exception:
error: could not create 'build': Permission denied
The reason obviously is that a regular user does not have write permissions within the gurobi directory (/opt/gurobi). Clearly, giving all gurobi users sudo permissions just to run this simple script is undesirable.
It seems that some modifications to the install script are required. Clearly a user should not require root access to install gurobi in a local python environment. Any suggestions? Can this be fixed in the next gurobi release?
-
It turns out, the solution is quite easy. Instead of invoking:
>python setup.py install
one can simply invoke:
> python setup.py build -b /tmp/gurobi install
The -b flag specifies a custom build directory. So in summary, to install gurobi in a venv environment without sudo permissions:
1. Create a virtual environment:
> python3 -m venv gurobi-env
2. Activate the virtual environment:
> source ./gurobi-env/bin/activate
3. Change to the gurobi install dir:
> cd /opt/gurobi811/linux64/
4. Install gurobi with a custom build path
> python setup.py build -b /tmp/gurobi install1 -
A dirty way to avoid the issue is to copy /opt/gurobi to a local/user directory, and run from there....
0
Please sign in to leave a comment.
Comments
2 comments