Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Fixing Pyrosetta Binaries to work with Anaconda Python on MacOSX

Fixing Pyrosetta Binaries to work with Anaconda Python on MacOSX

Assuming your Anaconda Python is at the front of your path (type 'which ipython' to verify that it is using the Anaconda version). Here, Anaconda is installed in ~/anaconda

System Commands are preceded with ">"

Python Commands are preceded with ">>"

If you download the Pyrosetta Binaries, unzip them, source the SetPyrosettaEnvironment.sh and run ipython while using Ananconda's version of Ipython, you may see the following error:

>>from rosetta import *
Fatal Python error: PyThreadState_Get: no current thread

This is because there is a mismatch in the python modules that are being loaded. You are running Anaconda Ipython and importing the associated modules. However, the default build for Pyrosetta is against the system install of Python (located somewhere like /System/Library/Frameworks/Python.framework/Versions/2.7/Python)

In fact, you can check the dependence of the Pyrosetta dynamic libraries (called rosetta.so in the main directory) by typing the following:

> otool -L rosetta.so 
  • rosetta.so:
    • /Volumes/scratch/benchmark/rosetta.Hikaru/master/main/source/build/PyRosetta/macos/monolith/release/build/../rosetta.so (compatibility version 0.0.0, current version 0.0.0)
    • /usr/lib/libstdc++.6.dylib (compatibility version 7.0.0, current version 104.1.0)
    • /usr/lib/libz.1.dylib (compatibility version 1.0.0, current version 1.2.5)
    • /System/Library/Frameworks/Python.framework/Versions/2.7/Python (compatibility version 2.7.0, current version 2.7.10)
    • /Users/steve/pyrosetta_download/PyRosetta.monolith.mac.master-58318/libboost_python.dylib (compatibility version 0.0.0, current version 0.0.0)
    • /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1213.0.0)

Note the line in Bold, where the rosetta.so binary calls the System Python library.... this leads to the crash mentioned above. The first step to fix this is to change the rosetta.so binary to use Anaconda's Python Library This can be achieved with the following command:

>install_name_tool -change /System/Library/Frameworks/Python.framework/Versions/2.7/Python /Users/steve/anaconda/lib/libpython2.7.dylib  rosetta.so

This fixes the rosetta.so binary, but we also need to change the libboost_python.dylib in the same directory

>install_name_tool -change /System/Library/Frameworks/Python.framework/Versions/2.7/Python /Users/steve/anaconda/lib/libpython2.7.dylib libboost_python.dylib

That's it! Now you should be able to successfully run:

>source SetPyrosettaEnironment.sh
>ipython
>> from rosetta import *
>> rosetta.init()

using Anaconda's I/Python!

Assuming your Anaconda Python is at the front of your path (type 'which ipython' to verify that it is using the Anaconda version).
Here, Anaconda is installed in ~/anaconda
System Commands are preceded with ">"
Python Commands are preceded with ">>"
If you download the Pyrosetta Binaries, unzip them, source the SetPyrosettaEnvironment.sh and run ipython while using Ananconda's version of Ipython, you may see the following error:
###>>from rosetta import *
Fatal Python error: PyThreadState_Get: no current thread
This is because there is a mismatch in the python modules that are being loaded. You are running Anaconda Ipython and importing the associated modules.
However, the default build for Pyrosetta is against the system install of Python (located somewhere like /System/Library/Frameworks/Python.framework/Versions/2.7/Python)
In fact, you can check the dependence of the Pyrosetta dynamic libraries (called rosetta.so in the main directory) by typing the following:
###> otool -L rosetta.so
rosetta.so:
/Volumes/scratch/benchmark/rosetta.Hikaru/master/main/source/build/PyRosetta/macos/monolith/release/_build_/../rosetta.so (compatibility version 0.0.0, current version 0.0.0)
/usr/lib/libstdc++.6.dylib (compatibility version 7.0.0, current version 104.1.0)
/usr/lib/libz.1.dylib (compatibility version 1.0.0, current version 1.2.5)
/System/Library/Frameworks/Python.framework/Versions/2.7/Python (compatibility version 2.7.0, current version 2.7.10)
/Users/steve/pyrosetta_download/PyRosetta.monolith.mac.master-58318/libboost_python.dylib (compatibility version 0.0.0, current version 0.0.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1213.0.0)
Note line 18, where the rosetta.so binary calls the System Python library.... this leads to the crash mentioned above. The first step to fix this is to change the rosetta.so binary to use Anaconda's Python Library
This can be achieved with the following command:
###install_name_tool -change /System/Library/Frameworks/Python.framework/Versions/2.7/Python /Users/steve/anaconda/lib/libpython2.7.dylib rosetta.so
This fixes the rosetta.so binary, but we also need to change the libboost_python.dylib in the same directory
###install_name_tool -change /System/Library/Frameworks/Python.framework/Versions/2.7/Python /Users/steve/anaconda/lib/libpython2.7.dylib libboost_python.dylib
That's it! Now you should be able to successfully run:
```
>source SetPyrosettaEnironment.sh
>ipython
>> from rosetta import *
>> rosetta.init()
```
using Anaconda's I/Python!
@dacarlin

This comment has been minimized.

Copy link

@dacarlin dacarlin commented Mar 17, 2016

If you happen to have the namespace build, you won't have a rosetta.so, but you can use

$ find . -name '*.so' -exec install_name_tool -change /System/Library/Frameworks/Python.framework/Versions
/2.7/Python /path/to/your/anaconda/lib/libpython2.7.dylib {} \;

to fix all the binaries in one go

@cuiyoutian

This comment has been minimized.

Copy link

@cuiyoutian cuiyoutian commented Apr 15, 2016

Perfect! Help me out.

@jasnyderjr

This comment has been minimized.

Copy link

@jasnyderjr jasnyderjr commented May 19, 2016

Is there a LINUX equivalent of install_name_tool so that the above can be used to "change the rosetta.so binary to use Anaconda's Python Library" on a general LINUX?

@sjbertolani

This comment has been minimized.

Copy link
Owner Author

@sjbertolani sjbertolani commented Jul 13, 2016

@jasnyderjr Hi, I just saw your comment. I am not aware that this problem exists on linux builds. I've only ever seen this in the mac builds. You can view your dependency libraries on linux ELF executables with ldd rosetta.so and I believe chrpath is the equivalent command (although I've never used that tool)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment