Skip the README, let us install for you

Ryan Mulligan

If you’ve ever tried to install a complex Python package, you know the pain of scouring the package’s README for the apt install or brew install commands necessary to bring in the system-level dependencies the package needs. This approach can be time-consuming and frustrating, especially when a cascade of errors indicates a missing system dependency — a pain point that isn't always immediately obvious.

You can now skip the README and let us install everything for you. Replit will automatically install the system dependencies needed for hundreds of Python packages. When you add a package via the Packages tool or automatically install a package via package guessing, Replit’s Universal Package Manager detects system dependencies needed for these packages. This also extends to packages already in your pyproject.toml file, and adds the relevant system dependencies to your Repl’s replit.nix file.

To illustrate the efficiency of this tool, let’s ask Replit AI to help us make a snowman. We’ll try to create a vector graphics image using Python’s pycairo library. To start, create a new Python Repl and select Generate Code with AI. Enter the prompt: “Using Python's pycairo, draw an SVG snowman. The snowman should have three balls of snow, a carrot nose, and two black eyes. Import math if you need it.”

Prompting Replit AI
Prompting Replit AI

The full code is available in this Repl.

Before automatic system dependency installation, you would have been greeted with an arcane error message like this, buried among hundreds of lines of output:

'pkg-config' not found. Command ['pkg-config', '--print-errors', '--exists', 'cairo >= 1.15.10'] ---------------------------------------- ERROR: Failed building wheel for pycairo Failed to build pycairo ERROR: Could not build wheels for pycairo which use PEP 517 and cannot be installed directly

Even if you knew to install the pkg-config program, you’d see another error message because pycairo depends on the cairo system package:

running build_ext Package cairo was not found in the pkg-config search path. Perhaps you should add the directory containing `cairo.pc' to the PKG_CONFIG_PATH environment variable No package 'cairo' found Command '['pkg-config', '--print-errors', '--exists', 'cairo >= 1.15.10']' returned non-zero exit status 1.

Replit's new approach eliminates these obstacles. When you Run the Repl, the necessary packages will automatically be added to your replit.nix file:

{pkgs}: {

  deps = [

    pkgs.pkg-config

    pkgs.libxcrypt

    pkgs.cairo

  ];
}

This installs the system dependencies, and the code generates a simple SVG snowman:

Snowman
Snowman

Using information from the Nixpkgs package repository, we’ve pre-populated system dependencies for over 700 Python libraries. This automation streamlines the process and significantly enhances productivity, allowing you to focus more on development and less on configuration.

We are committed to continually expanding this list, covering more packages and supporting additional programming languages. If you encounter a package that is not yet supported or have suggestions for improvement, please send us a Pull Request or let us know on the Ask Forum.

Interested in solving complex problems around developer tooling to empower the next billion software creators? Join our team!

More blog posts