[][src]Crate python_config


Just like the python3-config script that's installed with your Python distribution, python-config-rs helps you find information about your Python distribution.

use python_config::PythonConfig;

let cfg = PythonConfig::new(); // Python 3

// Print include directories
println!("Includes: {}", cfg.includes().unwrap());
// Print installation prefix
println!("Installation prefix: {}", cfg.prefix().unwrap());

python-config may be most useful in your build.rs script, or in any application where you need to find

  • the location of Python libraries
  • the include directory for Python headers
  • any of the things available via python-config

Essentially, this is a reimplementation of the python3-config script with a Rust interface. We work directly with your Python interpreter, just in case a python-config script is not on your system.

We provide a new binary, python3-config, in case (for whatever reason) you'd like to use this version of python3-config instead of the distribution's script. We have tests that show our script takes the exact same inputs and returns the exact same outputs. Note that the tests only work if you have a Python 3 distribution that includes a python3-config script.

3 > 2

We make the choice for you: by default, we favor Python 3 over Python 2. If you need Python 2 support, use the more explicit interface to create the corresponding PythonConfig handle. Note that, while the Python 2 interface should work, it's gone through significantly less testing.

The python3-config binary in this crate is Python 3 only.



Exposes Python configuration information



Describes a few possible errors from the PythonConfig interface


Selectable Python version

Type Definitions


The result type denotes that this function is only available when interfacing a Python 3 interpreter.


The result type denoting a return T or an Error.