How to install

Easy: Install using conda

The easiest way to install cctbx is through the Conda package manager. You can get a full environment from Anaconda or just the conda package manager with the Miniconda installer.

There are two packages available, cctbx and cctbx-base. The cctbx package is cctbx-base with some additional packages (wxpython, pyside2, ipython).

With the conda command available, a new cctbx-base environment named my_env can be created with

conda create -n my_env -c conda-forge cctbx-base

To choose a specific version of Python, add the python package with the specific version

conda create -n my_env -c conda-forge cctbx-base python=3.8

Then the environment can be activated with

conda activate my_env

To install cctbx-base into the currently active environment, use

conda install -c conda-forge cctbx-base

The python package with a specific version can be added to change the version of python that is already installed in the active environment.

Building a development version

1. Download in the directory where the cctbx and its dependencies shall be installed

2. Run python (you may want to run it with the --help option first to discover the available options).

For better compatibility with newer operating systems, you will want to use conda packages for dependencies. Add the --use-conda flag and the command becomes python --use-conda. This will run the miniconda installer if conda cannot be found. The environment with the dependencies will be located in the conda_base directory. See the description of the --use-conda flag from the --help output for more details.
The installation will take a long while (15 min - 1 hour, depending on your computer) but the script will verbosely describe what it does.

This creates the subdirectories base, build, and modules. The base directory contains dependencies for cctbx, build contains the compiled cctbx code, and modules contains the source code for cctbx. To keep in your installation directory up-to-date with the version in modules, you can create a symbolic link to that version:

cd <installation directory>
ln -s ./modules/cctbx_project/libtbx/auto_build/

Within the build directory, cctbx creates a file setpaths.csh (among others). This file must be used to initialize a new shell or process with the cctbx settings:

source setpaths.csh

There is also a for bash users.

To update your cctbx installation to the latest version, you can just run:

python ./

again in the <installation directory>. This will update the source code in the modules directory and recompile the changes (if necessary) in build. Occasionally, dependencies in base are updated. When this happens, just delete the base directory and rerun the command.

To compile any local changes to the source code, enter the build directory and run:


This will actually run the libtbx.scons command using all available CPUs. You can also manually specify the number of CPUs to use, for example:

libtbx.scons -j 4

Note that libtbx.scons is just a thin wrapper around SCons. The SCons documentation applies without modification.

To run scripts with cctbx imports use the command:


(You can also use scitbx.python, cctbx.python, iotbx.python, etc.; all these commands are equivalent.)

For example, to run some regression tests after the compilation is finished enter:

source build/setpaths_all.csh
libtbx.python $SCITBX_DIST/
libtbx.python $CCTBX_DIST/ --Quick

The output should show many OK. A Python Traceback is an indicator for problems.

SCons - the backbone of the cctbx build system

Conceptually it is a trivial task to compile and link portable source code. However, in real life this is one of the most time-consuming nuisances, in particular if multiple, diverse platforms have to be supported. In the version 1.0 release of the cctbx we made an attempt to address this with the home-made fast track build system. Of course home-made is often good enough, but a professional solution is almost always better, especially if it comes with no strings attached.

Fortunately such a system is now available: SCons, short for Software Construction tool. This is a perfect fit for the cctbx because the SCons developers have apparently adopted a similar “professional is better than home-made” philosophy: SCons is implemented in pure Python, and SCons configuration files (the equivalent of Makefiles) are pure Python scripts. SCons has many advantages compared to a traditional make-based build system. To quote some points from the SCons documentation:

  • Global view of all dependencies – no more multiple build passes or reordering targets to build everything.
  • Reliable detection of build changes using MD5 signatures – no more “clock skew detected, build may be incomplete”.
  • Built-in support for C, C++, Fortran, Yacc and Lex.
  • Improved support for parallel builds – like make -j but keeps N jobs running simultaneously regardless of directory hierarchy.
  • Building from central repositories of source code and/or pre-built targets.
  • Designed from the ground up for cross-platform builds, and known to work on Linux, POSIX, Windows NT, Mac OS X, Tru64 Unix, and OS/2.

When we moved from our home-grown build system to SCons we found all these points to be perfectly true. It only took very little effort to write a small configure script for setting up a master SConstruct file based on the user’s choice of which cctbx modules to use and which to ignore. New modules can easily be tied into this system simply by providing a SConstruct file in the module’s top-level directory. The author of the new module has complete control over the build process. The existing settings can simply be reused, customized, or totally replaced, all within one uniform and 100% platform-independent framework, the Python language.