Minimal pyo3 cargo.toml // calling Python from Rust

Calling Rust from Python works already.

This is for calling Python from Rust.

use pyo3::Python;

fn unary_arithmetic() {
    let gil = Python::acquire_gil();
    let py = gil.python();


pyo3 =                                                         { version = "0.12.4", features = ["extension-module"] }

When I try to run this, I get 'undefined reference to Py_***'

I suspect the problem is that I am not properly linking against Python.

How do I fix this ?

Your problem is described here:

1 Like