Installation#

Note

If you want to install the development version of cocotb, instructions are here.

pip is the officially supported and recommended package manager for installing cocotb. cocotb is also packaged by third parties to support installation via alternative package managers; see Installation via Alternative Package Managers for details. For more installation options, please visit our Wiki.

Install with pip#

Install Prerequisites#

The current stable version of cocotb requires:

  • Python 3.9+

  • libpython 3.9+ which matches the Python version

The installation instructions vary depending on your operating system:

We recommend users who are more comfortable with native Windows development to use Conda. Conda is an open-source package and environment management system available on Windows.

Download and install Miniconda from https://conda.io/. From an Anaconda Prompt, use the following line to install a compiler (GCC or Clang) and GNU Make:

conda install -c msys2 m2-base m2-make

We recommend users who are running Windows and who are more comfortable with a Unix shell, or who have legacy Makefile-based projects, to use Windows Subsystem for Linux (WSL).

Follow the Microsoft WSL installation guide to install WSL with a supported Linux distribution. Then follow the appropriate Linux installation instructions for cocotb.

In a terminal, run

sudo apt-get install make python3 python3-pip libpython3-dev

In a terminal, run

sudo yum install make python3 python3-pip python3-libs

We recommend using the Homebrew package manager. After installing it, run the following line in a terminal:

brew install python

Install cocotb#

The latest stable version of cocotb can be installed by running

pip install cocotb

Note

If your user does not have permissions to install cocotb using the instructions above, try adding the --user option to pip (see the pip documentation).

Warning

pip may belong to a different Python installation to what you expect. Use pip -V to check. If this prints “(python 2.7)”, use pip3 or python3 -m pip in place of pip in the command shown.

Verify Installation#

After installation, you should be able to execute the following command:

cocotb-config --version

If the command is not found, you need to append its location to the PATH environment variable.

Verify the version printed matches the version you intended to install.

Installation via Alternative Package Managers#

In a terminal, run

guix install python-cocotb