Python module error on Linux

I use python 2.7 on Linux Mint 16. I encountered an error if I run my IDE (tried it in Spyder and Pycharm) from a launcher (for example, from an invitation to Alt F2 or an icon shortcut to my desktop), the modules do not load and I get the following error:

 File "/usr/local/lib/python2.7/dist-packages/gurobipy/__init__.py", line 1, in 
     from .gurobipy import *
 ImportError: libgurobi56.so: cannot open shared object file: No such file or directory

However, if I run the program from the command line, the modules load correctly and the program works fine. I have only one installation of each of the IDEs. The output of sys.path from two instances is as follows:

Exiting sys.path to start Pycharm from the shortcut:

 /home/XXXXXX/bin/pycharm-community-3.1.3/helpers/pydev ',' /usr/local/lib/python2.7/dist-packages/pip-1.5.5-py2.7.egg ',' /usr/lib/python2.7 ',' /usr/lib/python2.7/plat-x86_64-linux-gnu ',' /usr/lib/python2.7/lib-tk ',' / usr / lib / python2.7 / lib-old ',' /usr/lib/python2.7/lib-dynload ',' /usr/local/lib/python2.7/dist-packages ',' /usr/lib/python2.7 / dist-packages ',' /usr/lib/python2.7/dist-packages/PILcompat ',' /usr/lib/python2.7/dist-packages/gtk-2.0 ',' / home / XXXXXX / PycharmProjects / untitled8 '] 

sys.path oyutput to start Pycharm from the command line:

 /home/XXXXXX/bin/pycharm-community-3.1.3/helpers/pydev ',' /usr/local/lib/python2.7/dist-packages/pip-1.5.5-py2.7.egg ',' /usr/lib/python2.7 ',' /usr/lib/python2.7/plat-x86_64-linux-gnu ',' /usr/lib/python2.7/lib-tk ',' / usr / lib / python2.7 / lib-old ',' /usr/lib/python2.7/lib-dynload ',' /usr/local/lib/python2.7/dist-packages ',' /usr/lib/python2.7 / dist-packages ',' /usr/lib/python2.7/dist-packages/PILcompat ',' /usr/lib/python2.7/dist-packages/gtk-2.0 ',' / home / XXXXXX / PycharmProjects / untitled8 ']

The gurobipy package is located in / usr / lib / python 2.7 / dist-packages

Installation procedure for the gurobi package:

1) Unallocated boot to / opt / gurobi 562 / linux64

2) Added the following lines to .bashrc

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

3) In / opt / gurobi 562 / linux64 running python setup.py install, this created the gurobipy folder in / usr / local / lib / python 2.7

4) Added the following line to .bashrc

 export LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:/usr/local/lib/python2.7/dist- packages/gurobipy" 
+8
python linux pycharm spyder linuxmint
source share
2 answers

You do not set the path to gurobipy.

Then download untar to /opt .

 cd to `/opt/gurobi562/linux64` and run `python setup.py install` 

Add the following to ~/.bashrc .

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

From bash, type source ~/.bashrc

start the ipython shell and try from gurobipy import * , it should work fine, the only error it will give is not to have a license if you have not downloaded and installed it from here

To set up system access, first create

 sudo gedit /etc/ld.so.conf.d/gurobi_pi.conf 

Then add

 /opt/gurobi562/linux64/lib 

and save the file.

Then enter

 sudo ldconfig 

to update libraries in the system. You must have access to shared libs in Pycharm.

+15
source share

You see a different behavior because your .bashrc always loads before starting PyCharm (or other editors) from the terminal. Other shortcuts don't know anything about your .bashrc , and they shouldn't. This module seems to require a very interesting configuration.

It’s best not to use the terminal every time to change the keyboard shortcuts you use (what you need to figure out) to set the correct environment variables. The most important of these variables are LD_LIBRARY_PATH .

 export LD_LIBRARY_PATH="/opt/gurobi562/linux64/lib:/usr/local/lib/python2.7/dist- packages/gurobipy" 

Warning: dist- packages seem strange, but I copied it from your question. If this does not work, you need to find out what the correct directory name is.

+1
source share

All Articles