ModuleNotFoundError#

ModuleNotFoundError: No module named <’_bz2’, ‘_sqlite3’>#

Users may experience a ModuleNotFoundError for some Python provided packages on their local machine.

Observed Error#

This line of code

import bz2

gives error:

Traceback (most recent call last):
import bz2
File "/usr/local/lib/python3.7/bz2.py", line 19, in <module>
    from _bz2 import BZ2Compressor, BZ2Decompressor
ModuleNotFoundError: No module named '_bz2'

Explanation#

Python installation was built from source but didn’t have all necessary system packages installed for full Python build.

Work around#

Install bzip2-devel and sqlite-devel and rebuild Python, or download a pre-built Python binary.

ModuleNotFoundError: No module named <…>#

Users may experience a ModuleNotFoundError for some Python packages that are available on their local machine.

Explanation#

Packages installed locally that aren’t available by default in the Cerebras Wafer Scale Cluster must be shared by their locations to --mount_dirs and --python_paths as described in Setup Cerebras virtual environment. We also have a experimental feature to avoid additional setup, more information at Seamlessly import user-specific dependency packages to Cerebras environment.

Work around#

Add custom packages to your Cerebras environment by:

  • pip install the packages in virtual environment

  • Copy the custom package directory from venv/lib/python3.7/site-packages/<package_name> to a NFS-mountable location for the Cerebras cluster. Only copy the custom packages, not the entire virtual environment.

  • Make sure to add this location to the --mount_dirs command line argument and the corresponding parent location to the --python_paths command line argument when calling run.py.