0

When trying to run my code in Pycharm i get this error:

from .gurobipy import *
ImportError: libgurobi80.so: cannot open shared object file: No such file or directory

In the regular python terminal i can import gurobipy with no problem. How can Pycharm be fixed?

I've read the install instructions and posted the following 3 lines at the end of the bashrc file with a text editor.

export GUROBI_HOME="/opt/gurobi800/linux64"
export PATH="${PATH}:${GUROBI_HOME}/bin"
export LD_LIBRARY_PATH="${GUROBI_HOME}/lib"

Reinstalling PyCharm (even switching to EDU and Professional) as well as reinstalling Ubuntu did not change the error. Please help.

cheesus
  • 1,111
  • 1
  • 16
  • 44
  • 4
    Possible duplicate of [How to resolve ImportError in Gurobi?](https://stackoverflow.com/questions/42798173/how-to-resolve-importerror-in-gurobi) – Matias Cicero Jun 07 '18 at 22:47
  • Wouldn't it work to add these exports to `.profile` instead of `.bashrc`? – User9123 Nov 06 '21 at 23:14

3 Answers3

4

I had the same error and configured PyCharm on Kubuntu by adding the environment variables to the run config.

Select Edit configurations... and add the variables to the Environment variables field. In my case, I added GUROBI_HOME, LD_LIBRARY_PATH and GRB_LICENSE_FILE. Also, I had to enter the values directly: LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$GUROBI_HOME/lib didn't work, but LD_LIBRARY_PATH=/path/to/gurobi/lib works.

Code completion and suggestions still don't work, but at least I can run from PyCharm now.

drali
  • 307
  • 1
  • 12
  • 1
    I had the same problem with PyCharm and Gurobi on Ubuntu. This solved the problem! Thanks – Mehdi Mar 02 '20 at 13:01
0

I went around this problem by just editing the file in PyCharm and running it via the terminal. I didn't find another solution so far, so I'm still proceeding this way. It seems to be a PyCharm-specific problem.

cheesus
  • 1,111
  • 1
  • 16
  • 44
0

I tried more than 10 ways to install Gurobipy in Pycharm. However, there is no way to use.

There are two days to use Gurobipy

  1. Jupyter based on Conda - installation : recommended by Grobipy.

  2. Install Grobipy indirectly to python (This Is what i did for my setting)

Hope Pycharm and Gurobipy to work together to resolve this issue. But most people might use Jupyter these days. So don’t know how much they will be interested in fixing this.