Software⏱️ 3 min read📅 2026-06-04

How to Fix: Ubuntu running `pip install` gives error 'The following required packages can not be built: * freetype'

pip install error due to missing freetype package

Quick Answer: Try installing the required packages using apt-get before running pip install, e.g. apt-get install libfreetype6-dev

Ubuntu users may encounter an error when running `pip install` that prevents them from installing certain packages, including matplotlib. This issue affects users who have installed Ubuntu and are trying to install dependencies required by their project.

The error message 'The following required packages can not be built: * freetype' is frustrating for developers as it blocks the installation of essential libraries like dateutil and tornado.

🛑 Root Causes of the Error

  • The primary reason for this error is the lack of a compatible version of the FreeType library, which is a dependency for many packages. Ubuntu's default package manager may not have the latest version installed.
  • Another possible cause could be an issue with the package index or repository configuration, which might lead to missing dependencies.

🔧 Proven Troubleshooting Steps

Updating the Package Index and Installing Required Packages

  1. Step 1: Open a terminal and run `sudo apt update` to refresh the package list.
  2. Step 2: Then, install the required packages using `sudo apt install libfreetype6-dev`.
  3. Step 3: This will ensure that the necessary dependencies are installed before proceeding with the installation of matplotlib.

Using pip to Install Required Packages

  1. Step 1: Run `pip install --upgrade pip` to update pip to the latest version.
  2. Step 2: Then, use `pip install -r requirements.txt --no-deps` to install the required packages without dependencies.

🎯 Final Words

To resolve the issue of Ubuntu running `pip install` and encountering the 'The following required packages can not be built: * freetype' error, try updating the package index and installing required packages using the steps outlined in Method 1. Alternatively, use pip to install required packages without dependencies as described in Method 2.

Did this fix your problem?

If not, try searching for specific error codes.

🔍 Search Error Database

❓ Frequently Asked Questions