Issues with Gurobi 7.5.1 installation on Mac

896 views
Skip to first unread message

Rennan Chagas

unread,
Oct 4, 2017, 9:21:59 AM10/4/17
to Gurobi Optimization
Hi guys!

I am trying to finish installation of Gurobi on my Mac. I already runned license setup, Gurobi package installation and runned setup.py on installation folder.

However, when I try to import gurobipy in ipython to test if everything is ok I receive this error message:

ImportError: dlopen(/Users/rennan/anaconda3/lib/python3.6/site-packages/gurobipy/gurobipy.so, 2): Library not loaded: /Library/Frameworks/Python.framework/Versions/3.6/Python

  Referenced from: /Users/rennan/anaconda3/lib/python3.6/site-packages/gurobipy/gurobipy.so

  Reason: image not found


Any ideas on how to solve this?

Rennan Chagas

unread,
Oct 6, 2017, 3:27:56 PM10/6/17
to Gurobi Optimization
I tried some things, reinstalling everything (Gurobi and anaconda) and the error persists. Also removed anaconda and Gurobi once again and tried to run with a pure python distro installed with homebrew

Now I get the same error message 

Rennans-MacBook-Pro:~ rennan$ ipython

Python 3.6.3 (default, Oct  4 2017, 06:09:15) 

Type 'copyright', 'credits' or 'license' for more information

IPython 6.2.1 -- An enhanced Interactive Python. Type '?' for help.


In [1]: import gurobipy

---------------------------------------------------------------------------

ImportError                               Traceback (most recent call last)

<ipython-input-1-c7d4163ca846> in <module>()

----> 1 import gurobipy


/usr/local/lib/python3.6/site-packages/gurobipy/__init__.py in <module>()

----> 1 from .gurobipy import *


ImportError: dlopen(/usr/local/lib/python3.6/site-packages/gurobipy/gurobipy.so, 2): Library not loaded: /Library/Frameworks/Python.framework/Versions/3.6/Python

  Referenced from: /usr/local/lib/python3.6/site-packages/gurobipy/gurobipy.so

  Reason: image not found

Neal Young

unread,
Nov 8, 2017, 12:29:36 AM11/8/17
to Gurobi Optimization
I have the same issue, on just one of two computers on which I have gurobipy installed.  Not sure what the problem is.

I noticed that in spite of having the same version numbers, the two installs had differing gurobipy.so files. 
I copied the file from the working installation to the broken one, then reran 'sudo python setup.py install', and 
that seems to have helped.  

Below are the shasums for the now-working gurobipy.so and the broken versions.  
I did the above fix twice: once for python3.6 and once for python2.7:

> pwd

/Library/gurobi751/mac64/lib/python2.7/gurobipy


> ls -l

total 8248

-rwxrwxr-x  1 root  admin       24 Jul 15 10:19 __init__.py*

-rwxrwxr-x  1 root  admin  2106992 Jul 15 10:19 gurobipy-broken.so*

-rwxr-xr-x  1 neal  staff  2106992 Nov  7 19:02 gurobipy.so*


> shasum *

eb3a99fb2a57639d4b84c46dd30e1a1ad643683b  __init__.py

fd3400e35fe36e2f1d1531f74b5c79b876fd6515  gurobipy-broken.so

4e9f1684fa55ac72a53f4b39edb3272f24acb78f  gurobipy.so


> cd ../../python2.7/gurobipy/


> pwd

/Library/gurobi751/mac64/lib/python2.7/gurobipy


> ls -l

total 8840

-rwxrwxr-x  1 root  admin       24 Jul 15 10:19 __init__.py*

-rwxrwxr-x  1 root  admin  2258468 Jul 15 10:19 gurobipy-broken.so*

-rwxr-xr-x  1 neal  staff  2258468 Nov  7 19:04 gurobipy.so*


> shasum *

eb3a99fb2a57639d4b84c46dd30e1a1ad643683b  __init__.py

d2f672faedb6639d1148e8e77ceb6eb54c94731c  gurobipy-broken.so

5047b756e74c3abe02860e54c3a901710f0a31d2  gurobipy.so

Michael Winkler

unread,
Nov 8, 2017, 11:36:36 AM11/8/17
to Gurobi Optimization
Hi Neal,

1. Do you have different versions of Gurobi on both machines?

2. Do you have different Mac OS versions on these machines?

3. Your "broken" files actually show the correct checksums. Did you change something on the gurobipy.so files? Can you do an "otool -L" on them and post the result.

4. What did actually not work with the "broken" files?

Best,
Michael

Neal Young

unread,
Nov 8, 2017, 12:03:16 PM11/8/17
to Gurobi Optimization


On Wednesday, November 8, 2017 at 8:36:36 AM UTC-8, Michael Winkler wrote:
Hi Neal,

1. Do you have different versions of Gurobi on both machines?

The version number on both is Gurobi 7.5.1.
 
2. Do you have different Mac OS versions on these machines?

Both have 10.13.1 (17B48).  One is an mac mini, the other is a macbook air.

3. Your "broken" files actually show the correct checksums. Did you change something on the gurobipy.so files? Can you do an "otool -L" on them and post the result.

> otool -L gurobipy-broken.so 

python3.6:

gurobipy-broken.so:
gurobipy36/gurobipy.so (compatibility version 7.5.0, current version 7.5.1)
/Library/gurobi751/mac64/lib/libgurobi75.so (compatibility version 7.5.0, current version 7.5.1)
/Library/Frameworks/Python.framework/Versions/3.6/Python (compatibility version 3.6.0, current version 3.6.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1226.10.1)

> otool -L gurobipy.so
gurobipy.so:
gurobipy36/gurobipy.so (compatibility version 7.5.0, current version 7.5.1)
/Library/gurobi751/mac64/lib/libgurobi75.so (compatibility version 7.5.0, current version 7.5.1)
/opt/local/Library/Frameworks/Python.framework/Versions/3.6/lib/libpython3.6.dylib (compatibility version 3.6.0, current version 3.6.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1226.10.1)

python2.7:

> otool -L gurobipy-broken.so 
gurobipy-broken.so:
gurobipy27/gurobipy.so (compatibility version 7.5.0, current version 7.5.1)
/Library/gurobi751/mac64/lib/libgurobi75.so (compatibility version 7.5.0, current version 7.5.1)
/System/Library/Frameworks/Python.framework/Versions/2.7/Python (compatibility version 2.7.0, current version 2.7.10)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1226.10.1)
 
> otool -L gurobipy.so
gurobipy.so:
gurobipy27/gurobipy.so (compatibility version 7.5.0, current version 7.5.1)
/Library/gurobi751/mac64/lib/libgurobi75.so (compatibility version 7.5.0, current version 7.5.1)
/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/libpython2.7.dylib (compatibility version 2.7.0, current version 2.7.10)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1226.10.1)
 
 
4. What did actually not work with the "broken" files?
 
In python3.6 I was unable to "import gurobipy".  I got the same error that was reported above in the first message in this thread.
In python2.7 importing gurobipy caused a segmentation violation.

I'm guessing that the working gurobipy.so libs were from an install I did in July or August.

-Neal

Neal Young

unread,
Nov 8, 2017, 12:03:21 PM11/8/17
to Gurobi Optimization

4. What did actually not work with the "broken" files?

Actually my output was slightly different since i did not install with anaconda.
Here is the output from "import gurobipy" in python3.6 with the "broken" gurobipy.so:

> python3.6
Python 3.6.3 (default, Oct  7 2017, 02:03:21) 
[GCC 4.2.1 Compatible Apple LLVM 9.0.0 (clang-900.0.37)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import gurobipy
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Library/gurobi751/mac64/lib/python3.6/gurobipy/__init__.py", line 1, in <module>
    from .gurobipy import *
ImportError: dlopen(/Library/gurobi751/mac64/lib/python3.6/gurobipy/gurobipy.so, 2): Library not loaded: /Library/Frameworks/Python.framework/Versions/3.6/Python
  Referenced from: /Library/gurobi751/mac64/lib/python3.6/gurobipy/gurobipy.so
  Reason: image not found

Here is the output from python2.7:

> python2.7
Python 2.7.14 (default, Sep 27 2017, 12:15:00) 
[GCC 4.2.1 Compatible Apple LLVM 9.0.0 (clang-900.0.37)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import gurobipy
fish: Job 1, “python2.7” terminated by signal SIGSEGV (Address boundary error)

Neal Young

unread,
Nov 8, 2017, 12:05:47 PM11/8/17
to Gurobi Optimization
And here are how the environment vars are set, if it matters:

> echo $LD_LIBRARY_PATH 
/Library/gurobi751/mac64/lib

> echo $PATH
. ./bin ../bin /Users/neal/Bin /usr/local/bin /Library/TeX/texbin /opt/local/bin /opt/local/sbin . ./bin ../bin /Users/neal/Bin /usr/local/bin /Library/TeX/texbin /opt/local/bin /opt/local/sbin /usr/local/bin /usr/bin /bin /usr/sbin /sbin /Library/TeX/texbin /Library/gurobi751/mac64/bin

> echo $GUROBI_HOME 
/Library/gurobi751/mac64


Michael Winkler

unread,
Nov 8, 2017, 1:20:17 PM11/8/17
to Gurobi Optimization

python2.7:

> otool -L gurobipy-broken.so 
gurobipy-broken.so:
gurobipy27/gurobipy.so (compatibility version 7.5.0, current version 7.5.1)
/Library/gurobi751/mac64/lib/libgurobi75.so (compatibility version 7.5.0, current version 7.5.1)
/System/Library/Frameworks/Python.framework/Versions/2.7/Python (compatibility version 2.7.0, current version 2.7.10)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1226.10.1)
 
> otool -L gurobipy.so
gurobipy.so:
gurobipy27/gurobipy.so (compatibility version 7.5.0, current version 7.5.1)
/Library/gurobi751/mac64/lib/libgurobi75.so (compatibility version 7.5.0, current version 7.5.1)
/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/libpython2.7.dylib (compatibility version 2.7.0, current version 2.7.10)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1226.10.1)
 

It seems like you changed the python reference from /System/Library/Frameworks/Python.framework/Versions/2.7/Python to /opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/libpython2.7.dylib with probably install_name_tool because you have a non-standard python installation. This explains the different checksums and also why it is working for you.

Best,
Michael

P.S. Thanks for the detailed information.
Reply all
Reply to author
Forward
0 new messages