How to use gurobipy with multiple versions of gurobi installed
AnsweredHello,
So we have multiple versions of gurobi installed as modules on our HPC system, with their own respective module files that set the required environment variables and paths for each. It's just come to our attention that gurobipy only functions with the latest version we have installed - which is 10.0.1. When I try to import gurobipy it throws the following error "ImportError: libgurobiXX.so: cannot open shared object file: No such file or directory" but will be looking for the wrong version. We have the following versions installed: gurobi/10.0.1 gurobi/7.0.2 gurobi/8.1.1 gurobi/9.0.3 gurobi/9.1.2
For example:
[root@w]# module load gurobi/7.0.2
[root@w]# python
Python 2.7.15 | packaged by conda-forge | (default, Feb 28 2019, 04:00:11)
[GCC 7.3.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import gurobipy
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/wsu/el7/pre-compiled/python/2.7/lib/python2.7/site-packages/gurobipy/__init__.py", line 1, in <module>
from .gurobipy import *
ImportError: libgurobi90.so: cannot open shared object file: No such file or directory
[root@w]# module load gurobi/9.0.3
[root@w]# python
Python 3.7.3 (default, Mar 27 2019, 22:11:17)
[GCC 7.3.0] :: Anaconda, Inc. on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import gurobipy
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/wsu/el7/pre-compiled/python/3.7/lib/python3.7/site-packages/gurobipy/__init__.py", line 1, in <module>
from .gurobipy import *
ImportError: libgurobi100.so: cannot open shared object file: No such file or directory
I initially thought that maybe only one version will work per version of python - but the older version with python 2.7 doesn't function either. Does this mean gurobipy can only be available for one version of gurobi? Is there a certain way that it should be installed or handled to have multiple versions available? My tentative solution is to simply have users install older versions in a conda environment if they wish to use gurobipy. Any insights and assistance will be appreciated!
-
Hi,
You can find the Python versions supported here: Which Python versions are supported by Gurobi?
You can install them easily with conda (or pip).
This doesn't require system environment variables as the package is self-contained.
Please try removing the packages you have now and installing via conda (pick an appropriate version): How do I install Gurobi for Python?If this doesn't work for you (e.g. you want to keep using the module load approach), then the system environment variables have to be set as indicated in How do I install Gurobi Optimizer? (in the Linux bit).
To change the Gurobi version, the system environment variables also have to be updated.Cheers,
David0
Please sign in to leave a comment.
Comments
1 comment