Setup & installation

This section provides an opinionated guide to setting up your development environment for working with Rust and Python. If you're an experienced developer in either language, feel free to skip this section.

Python

For macOS/Linux users, it's recommended to manage Python versions using pyenv. pyenv lets you easily switch between multiple versions of Python. It's simple, unobtrusive, and follows the UNIX tradition of single-purpose tools that do one thing well.

Follow the instructions from the installation steps section of the README to install pyenv on your system.

Windows users can use pyenv-win, a fork of pyenv that allows you to install and manage Windows-native Python versions.

Python version

This book uses Python 3.11.x, though code run from Python 3.8+ should also work without issues. You can install the latest minor version using pyenv:

pyenv install 3.11.7

Virtual environments

It's recommended to use virtual environments to manage your Python dependencies. This allows you to create isolated environments for each project, and avoid dependency conflicts between projects.

The venv module is included in the Python standard library, so you don't need to install anything extra to use it.

To create a virtual environment on Unix systems, run the following command:

# Setup a new environment for the first time
python -m venv venv
# Activate the environment
source venv/bin/activate

On Windows, it's more or less the same:

py -m venv .venv
.venv\Scripts\activate

You can deactivate the environment by running deactivate in your shell.

Rust

For macOS/Linux users, rustup is the recommended to manage Rust versions. Using this tool, you can easily switch between multiple versions of Rust, and it also ships with the cargo package manager.

See the Rust Book for instructions on how to install rustup on Windows.

Rust version

This book uses Rust 1.75.x. You can install the latest minor version using rustup:

rustup install 1.75.0

You can start a new Rust project in your local directory by running cargo new <project-name>, and you're ready to go!