Skip to content

Guide · Open source

How to use RustPython: install, run scripts and embed it

Updated · written with AI from the project's own documentation and checked against our catalogue data

RustPython is an implementation of the Python programming language written in Rust instead of C, the language CPython is written in. This guide shows you how to build it from source, run Python code with it, and where it can and cannot be used today. By the end you will be able to run a Python command or the interactive shell and know which use cases the project itself recommends.

RustPythonRustPython/RustPython · ★ 22.5k · MIT

Quick start

  1. 1Check your Rust toolchain. Run rustc --version to confirm Rust is installed. Run rustup update stable if you need the latest stable release.
  2. 2Clone the repository. Run git clone https://github.com/RustPython/RustPython to download the source code.
  3. 3Enter the project folder. Run cd RustPython to change into the project directory.
  4. 4Run a test command. Run cargo run --release -- -c 'print("Hello, RustPython!")' to confirm the build works. It should print Hello, RustPython!.
  5. 5Open the interactive shell. Run cargo run --release with no arguments to open the shell and type Python expressions at the >>> prompt.
  6. 6Install the binary (optional). Run cargo install --git https://github.com/RustPython/RustPython rustpython, then run rustpython from any folder.

What you need before installing RustPython

RustPython is installed by cloning the source code and building it with Cargo, Rust's build tool. You need the latest stable Rust toolchain and Git.

If you do not have Rust, follow the instructions at rustup.rs. To check which version you have, run rustc --version. To update to the most recent stable release, run rustup update stable.

  • Rust latest stable toolchain (via rustup.rs)
  • Git
rustc --version rustup update stable

Build and run RustPython from the source code

Clone the repository and change into its directory. Then run a one-line Python command. The README notes that --release is needed to prevent a stack overflow on Windows.

To use the interactive shell instead, run cargo run --release with no arguments. On Windows, set the RUSTPYTHONPATH environment variable to the Lib folder in the project directory, for example C:\RustPython\Lib if the project is in C:\RustPython.

git clone https://github.com/RustPython/RustPython cd RustPython cargo run --release -- -c 'print("Hello, RustPython!")' cargo run --release

Install the rustpython binary with Cargo

If you do not want to work inside the source tree, you can install the rustpython binary directly from the Git repository. After installing, run rustpython to open the interpreter.

cargo install --git https://github.com/RustPython/RustPython rustpython rustpython

Use a virtual environment and pip

The README says RustPython does not currently provide a well-packaged installation, so pip is harder to use directly. Creating a venv with RustPython makes pip easier to use. Pip needs HTTPS, so you first need an installed rustpython built with SSL support. The README says you can enable the ssl feature, and that on Windows you may need OpenSSL or the ssl-openssl-vendor feature, which requires a C compiler, perl and make. OpenSSL version 3 is expected.

The README also mentions a conda route, but says it is not officially supported and may be out of date.

  • Install with SSL support, then run rustpython --install-pip to install pip.
  • The conda route is: conda install rustpython -c conda-forge
rustpython -m venv <your_env_name> . <your_env_name>/bin/activate python

Run RustPython in a browser or WASI runtime

RustPython can be compiled to a standalone WebAssembly WASI module. The README gives a build command for the wasm32-wasip1 target and examples that run the resulting rustpython.wasm file with wasmer or wapm. You also need to add the target with rustup once.

The project also hosts an online demo running on WebAssembly, which you can try without installing anything.

  • Add the target once: rustup target add wasm32-wasip1
cargo build --release --target wasm32-wasip1 --features="freeze-stdlib"

Embed RustPython in a Rust application

If you want Python scripting inside a Rust program, the README points to two examples in the repository: examples/hello_embed.rs and examples/mini_repl.rs. The README gives this as the reason to use it: you can tweak logic with Python without waiting on Rust compile times.

The README describes the SSL setup for embedders: rustpython-stdlib offers a provider-agnostic ssl-rustls feature, or you can use ssl-openssl instead.

  • Read examples/hello_embed.rs for a minimal embed
  • Read examples/mini_repl.rs for a small REPL built on the interpreter

Know the limits before you rely on it

The README is clear that RustPython is in development and is not totally production-ready. Its stated goal is a full Python 3 environment entirely in Rust, not CPython bindings. It also says documentation is still in an early phase.

The README lists a very experimental JIT compiler, enabled with the jit cargo feature, which also requires autoconf, automake, libtool and clang. Treat it as experimental.

  • Not recommended for production workloads
  • Packaging and pip support are limited
  • Projects that need CPython C extensions are outside the stated goal
cargo run --features jit

What people use it for

  • Experimenting with a Python interpreter written in Rust
  • Adding Python scripting to a Rust application, as the README describes
  • Running Python in a WebAssembly or WASI environment
  • Studying interpreter internals as a contributor
  • Running Python in a browser through the project's online demo

Frequently asked questions

Is RustPython free to use?

RustPython is released under the MIT licence, as shown in the project's license badge. The source is on GitHub, and you can clone and build it yourself.

What do I need to install RustPython?

You need the latest stable Rust toolchain, installed through rustup.rs, and Git. You build it from source with Cargo using the commands in the README.

Is RustPython ready for production?

No. The README says RustPython is in development and not totally production-ready. Use it for experiments, embedding and learning rather than production workloads.

Can I use pip with RustPython?

Yes, but with extra steps. The README says the project lacks a well-packaged installation, so it recommends a venv. You need SSL support to install pip with rustpython --install-pip.

How does RustPython compare to CPython?

RustPython is written in Rust, while CPython is written in C. The README says RustPython aims for a full Python 3 environment in pure Rust, not CPython bindings. CPython is the standard, fully packaged interpreter, which the README does not claim RustPython replaces yet.

What are alternatives to RustPython?

The project lists CPython, PyPy and Ruff as comparable projects. Choose CPython for a standard, fully packaged Python, and PyPy for a different Python implementation. Ruff is a Python linter written in Rust, so it does a different job.

New agent skills, repos and AI tools — every week

The best new skills and open-source projects, the fastest-growing repos, and one free prompt. Five minutes to read. Unsubscribe anytime.

Our verdict

RustPython suits developers who want to experiment with a Rust-based Python interpreter, embed Python in a Rust app, or run Python in WebAssembly. It is a poor fit for production work or anyone who needs reliable pip and venv support, and the README says so directly. For everyday Python, use CPython.

Install options & downloads