We present PyCCE, an open-source Python library to simulate the dynamics of spin qubits in a spin bath, using the cluster-correlation expansion (CCE) method. PyCCE includes modules to generate realistic spin baths, employing coupling parameters computed from first principles with electronic structure codes, and enables the user to run simulations with either the conventional or generalized CCE method. We illustrate three use cases of the Python library: the calculation of the Hahn-echo coherence time of the nitrogen vacancy in diamond; the calculation of the coherence time of the basal divacancy in silicon carbide at avoided crossings; and the magnetic field orientation-dependent dynamics of a shallow donor in silicon. The complete documentation and installation instructions are available at https://pycce.readthedocs.io/en/latest/.