PyRosetta is an interactive Python-based interface to Rosetta, allowing users to create custom molecular modeling algorithms with Rosetta sampling and scoring functions using Python scripting. PyRosetta was written for Python 2.6, while the newer PyRosetta-4 require Python-3

PyRosetta is available as a separate download (independent of C++ Rosetta). See for more details. If you are a developer, it can also be compiled from source.

Installing and using PyRosetta-4

For details on how get and install PyRosetta-4 please consult our main web site at

[DEPRECATED] PyRosetta-3

  1. From within the main PyRosetta directory, run $ source or append it to your .bashrc file and source that.
  2. Test your PyRosetta installation by running the line import rosetta; rosetta.init() in Python. Output should be about the PyRosetta version and random seed.
    • Exiting the PyRosetta directory prior to running Python should help avoid path issues or confirm that your path is properly set.

PyRosetta-3 Namespace vs. monolith: According to Sergey, in the namespace build each C++ namespace has its own shared library which the kernel needs to load, resolve symbols, and so on. Hence, importing in the namespace build is IO heavy, but memory light. The monolith build on the other hand, has all the C++ namespaces defined in a single C++ library. For example, importing rosetta (via PyRosetta) in the namespace build on Stampede (NFS with high latency) could take up to 20 minutes. Doing the same with the monolith build would require about 7 seconds. The current recommendation is namespace for machines with memory constraints (e.g. less than 4 GB per thread) or for local development. For production runs on clusters (typically using the NSF filesystem), use monolith.

PyRosetta-4 Namespace vs monolith: Monolith version is the only PyRosetta-4 version. This monolith takes up a very small memory footprint as compared to PyRosetta-3 monolith version, as well as numerous other improvements.

IMPORTANT: DEVELOPERS, PLEASE DO NOT ADD GENERAL PyRosetta documentation to sections above, all such documentation should be instead placed at to avoid syncing issues when code evolved.

Building PyRosetta-4 from source

With the switch to C++11 in early September 2016, PyRosetta can now only be build with the PyRosetta-4 build scheme.

Prerequisites: You need to have Clang, CMake ( version > and Ninja installed.

To build PyRosetta:

cd main/source/src/python/PyRosetta
python -j8 --create-package path/to/package

cd ` --print-build-root`/setup
sudo python install
See the Dev Wiki for more.

To build under Conda:

To build under Conda, first create the environment you want to install the PyRosetta to, including the version of Python you wish to use. Then follow the instructions above.

It may be that the build script needs help finding the Python include files and libraries ("Could not find requested Python version"). When that happens, you can specify the path to the script

python -j8 --python-include-dir ${CONDA_PREFIX}/include/python* --python-lib ${CONDA_PREFIX}/lib/python* --create-package path/to/package

Note that you don't need to run with sudo if your conda environment is a user-level install.

Binding complex data-types to PyRosetta

If you are running a PyRosetta script and encounter this error or similar, "TypeError: Unable to convert value to a Python type!" - it means that the PyRosetta build did not bind the specific type of variable you're trying to access. This happens with complex data-structures that can hold other data-structures (such as a std::map, std::vector, std::list, utility::vector1, etc...). The solution is to declare a struct that inherits from this complex data type within the namespace and header file they're used.

For example, in class FragmentStore we have member variables of type std::map<std::string, std::vector<numeric::Size>> int64_groups, std::map<std::string, std::vector<numeric::Real>> real_groups, and std::map<std::string, std::vector< std::vector<numeric::Real>>> realVector_groups. When accessing these variables using fragment_store.int64_groups["Key"] in PyRosetta we receive the above error. The fix is declaring the following outside the class, but within the protocols::indexed_structure_store namespace:

struct map_std_string_std_vector_unsigned_long_std_allocator_unsigned_long_t : public std::map<std::string, std::vector<numeric::Size> > {};
struct map_std_string_std_vector_double_std_allocator_double_t : public std::map<std::string, std::vector<numeric::Real> > {};
struct map_std_string_std_vector_std_vector_double_std_allocator_double_std_allocator_std_vector_double_std_allocator_double_t : public std::map<std::string, std::vector<std::vector<numeric::Real>> > {};

The PyRosetta script can now access and change those member variables in FragmentStore

Locations for PyRosetta applications


Unknown at this time.


Rosetta developers creating new PyRosetta applications should place any public apps in main/source/src/python/bindings/app/ so that they will be packaged and distributed with PyRosetta. These public apps should also have accompanying integration tests. Private scripts should be placed in main/source/scripts/pyrosetta/pilot/<user_name>.

Additional Documentation

More extensive PyRosetta-specific documentation is available:

A general overview of the general Rosetta object structure and organization can be found here:

The PyRosetta Toolkit

The PyRosetta Toolkit GUI is a graphical frontend to PyRosetta written in Python. A Tutorial and overview of the code base and how to extend it for your own uses can be found here.

Note that currently, the PyRosetta Toolkit and other published apps are only distributed with PyRosetta-3

See Also