Ubuntu running `pip install` gives error 'The following required packages can not be built: * freetype'
Solution 1
No. pip
will not install system-level dependencies. This means pip
will not install RPM(s) (Redhat based systems) or DEB(s) (Debian based systems).
To install system dependencies you will need to use one of the following methods depending on your system.
Ubuntu/Debian:
apt-get install libfreetype6-dev
To search for packages on Ubuntu/Debian based systems:
apt-cache search <string>
e.g:
apt-cache search freetype | grep dev
Redhat/CentOS/Fedora:
yum -y install freetype-devel
To search for packages on Redhat/CentOS/Fedora based systems:
yum search <string>
e.g:
yum search freetype | grep devel
Mac OS X: (via Homebrew)
brew install freetype
To search for packages on Mac OS X based systems:
brew search <string>
e.g:
brew search freetype
Solution 2
I had to install libxft-dev in order to enable matplotlib on ubuntu server 14.04.
sudo apt-get install libfreetype6-dev libxft-dev
And then I could use
sudo easy_install matplotlib
Solution 3
A workaround is to do sudo apt-get install pkg-config
which I found in this github issue.
Solution 4
None of the existing answers worked for me to upgrade matplotlib on Ubuntu. This is what ultimately work for me:
$ sudo apt-get install build-dep python-matplotlib
$ pip install matplotlib --upgrade
Solution 5
This command will download all dependencies.
For python 2.x
sudo apt-get install python-matplotlib
For python 3.x
sudo apt-get install python3-matplotlib
After installing, you can try
(sudo) pip install matplotlib
Athena Wisdom
Updated on April 22, 2022Comments
-
Athena Wisdom about 2 years
When performing
pip install -r requirements.txt
, I get the following error during the stage where it is installingmatplotlib
:REQUIRED DEPENDENCIES AND EXTENSIONS numpy: yes [not found. pip may install it below.] dateutil: yes [dateutil was not found. It is required for date axis support. pip/easy_install may attempt to install it after matplotlib.] tornado: yes [tornado was not found. It is required for the WebAgg backend. pip/easy_install may attempt to install it after matplotlib.] pyparsing: yes [pyparsing was not found. It is required for mathtext support. pip/easy_install may attempt to install it after matplotlib.] pycxx: yes [Couldn't import. Using local copy.] libagg: yes [pkg-config information for 'libagg' could not be found. Using local copy.] freetype: no [pkg-config information for 'freetype2' could not be found.]
...
The following required packages can not be built: * freetype
Shouldn't
pip install -r requirements.txt
also install freetype? How should freetype be installed in Ubuntu 12.04 so it works withmatplotlib
? -
James Mills over 10 yearsSorry it's called
freetype2
these days. Updated. -
Athena Wisdom over 10 years
apt-get install freetype2-devel
gives the same error too... Could it beapt-get install freetype*
? That seems to want to install many other packages -
James Mills over 10 yearsThat will probably work too :) Sorry I believe it's called
libfreetype2-devel
. I'll updates my answer again :/ -
Dietrich Epp over 10 yearsI think the
-devel
convention is for RPM and the-dev
convention is for DEB. Tryapt-cache search '^libfreetype.*-dev$'
which giveslibfreetype6-dev
. -
James Mills over 10 years@DietrichEpp Thanks :) Bit hard to test without access to Debian/Ubuntu machines :/ Our work only uses RHEL/CentOS :)
-
Dietrich Epp over 10 yearsYou can always use packages.ubuntu.com if you don't have access to a computer running Ubuntu.
-
James Mills over 10 years@DietrichEpp Yeah I did but had trouble finding the right package because of the dev vs. devel convention -- Got myself confused :)
-
Nate about 10 yearsfwiw,
brew install freetype
helped me on OSX -
toom almost 10 yearsOn Ubuntu 12.04 LTS I also needed to install libxft-dev. Thanks for this extra info
-
Timo over 9 yearsWhy not directly use sudo apt-get install python-matplotlib as recommended here: matplotlib.org/users/installing.html
-
wim over 9 yearsI already had libfreetype6-dev installed. This helped for me on ubuntu 14.10, thanks!
-
TerminalDilettante about 9 yearsthe libxft-dev thing is what did it for me! thanks!
-
SlimJim about 9 yearsinstalling
pkg-config
was the missing unintuitive step for me as well, this when installingmatplotlib
in a docker container withubuntu:14.04
as base-image. -
Carles Sala over 8 yearsApparently, the real dependency here is
pkg-config
, whichlibxft-dev
also installs as a dependency. So, the right answer would be to runapt-get install libfreetype6-dev pkg-config
-
lababidi about 8 yearsMac OS X Users:
brew install pkg-config
will helppip
findfreetype
-
Alma almost 8 yearsThis also fixed it for me as well on a virtualbox VM. Looks like
pkg-config
is what is needed for virtual machine installations. -
Tristan almost 8 yearsblt-dev needs
apt-get install libfreetype6-dev
to run so it is automaticly installed with blt-dev. -
Hack-R almost 7 yearsUbuntu/Debian users also need the package in @Sudipta Basak's answer
-
xorinzor about 3 yearson WSL2 I also had to install
libxft-dev