Gurobipy is installed in my environment but cannot be found on my jupyter notebook
AnsweredI installed gurobi activating the academic license as explained in this post
Afterward, I did a `pip install -e` using the environment where I want gurobi to be installed.
I also tried with
python install setup.py
but this gives me an error:
error: package directory 'lib/python3.8_utf32/gurobipy' does not exist
Now if I run `pip list` from that environment I can see
gurobipy 10.0.1 <user_path>/opt/gurobi1001/linux64
However, if I now try to load gurobipy in a jupyter notebook using that specific virtual environment, I get an error saying
ModuleNotFoundError: No module named 'gurobipy'
I do not understand what I am doing wrong. Anyone can help?
-
Hi Kim,
To solve your problem, please try the following:
- make sure your environment is active,
- call pip uninstall gurobipy, or create a new environment,
- move to the directory of your Gurobi installation, which seems to be <user_path>/opt/gurobi1001/linux64 in your case,
- call python setup.py install. (Note that the order is different from what you tried above.)
Please let me know if this did not solve the issue.
Regarding your initial attempt, calling pip install -e <directory> creates a symbolic link to a directory, assuming that there is complete Python source code for a PIP project at that location, which is not the case here. This is a useful feature if you were actively developing the code at that location.
Best regards,
Lennart0 -
Hi Lennart,
First and foremost, thanks a lot for your quick reply.
First, I apologize for mistyping the command above python setup.py install in my message.
Also thanks for clarifying that the symbolic linking would not work in this case.
I tried what you suggested and I got this message./homes/knicoli/env/lib/python3.8/site-packages/setuptools/dist.py:173: SetuptoolsDeprecationWarning: Invalid config.
!!
********************************************************************************
newlines are not allowed in `summary` and will break in the future
********************************************************************************
!!
write_field('Summary', single_line(summary))
removing /homes/knicoli/opt/gurobi1001/linux64/buildIt does not seem to have worked because when I try to import gurobipy in the Jupyter notebook I get
--------------------------------------------------------------------------- ImportError Traceback (most recent call last) Cell In[3], line 13 ---> 13 from gurobi_samplers import gurobi_optimization File ~/project/gurobi_samplers.py:2 1 import numpy as np ----> 2 import gurobipy as gp 3 from gurobipy import GRB 5 def gurobi_optimization( 6 Q: np.ndarray): File ~/env/lib/python3.8/site-packages/gurobipy/__init__.py:1 ----> 1 from .gurobipy import * ImportError: libgurobi100.so: cannot open shared object file: No such file or directory
Any further suggestion?
0 -
Hi Kim,
Can you please try the below command, from within your active environment? This installs the gurobipy extension from the public PyPI server.
python -m pip install gurobipy
Best regards,
Lennart0 -
Hi Lennart,
Thanks a lot for your reply.
I did what you suggested. That indeed now finds gurobipy and allows me to import the library.
However, I now get the complaint my license cannot be found and get the following error:GurobiError: Unable to open Gurobi license file '~/gurobi.lic'
Any suggestions on how to resolve this?
The workflow I followed is the following.1. I ran grbgetkey <my_key> inside the environment
2. I moved the gurobi.lic file to /homes/knicoli/opt/gurobi1001 and set export GRB_LICENSE_FILE="~/opt/gurobi1001/gurobi.lic"
Am I doing something wrong, or shall I do this differently?
0 -
Hi Kim,
We recommend placing the license file in one of the following directories:
/opt/gurobi, /opt/gurobi1001 (for 10.0.1), or your home directory.If you place your license file in one of those directories, you do not need to set the GRB_LICENSE_FILE environment variable, so I recommend moving the file to one of the above paths.
If you prefer a non-default location, using "~" to refer to your home directory in the export call will not work. You can use export GRB_LICENSE_FILE="$HOME/opt/gurobi1001/gurobi.lic" instead. You can check your HOME environment variable using echo $HOME and see whether the output matches your expected path prefix.
0 -
Hi Lennart,
Wonderful, that worked!
Thank you so much for your quick and friendly support.
Best wishes,
Kim0
Please sign in to leave a comment.
Comments
6 comments