151

When performing pip install -r requirements.txt, I get the following error during the stage where it is installing matplotlib:

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 with matplotlib?

wim
  • 338,267
  • 99
  • 616
  • 750
Athena Wisdom
  • 6,101
  • 9
  • 36
  • 60

10 Answers10

229

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
Julien Marrec
  • 11,605
  • 4
  • 46
  • 63
James Mills
  • 18,669
  • 3
  • 49
  • 62
147

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
Sudipta Basak
  • 3,089
  • 2
  • 18
  • 14
30

A workaround is to do sudo apt-get install pkg-config which I found in this github issue.

notconfusing
  • 2,556
  • 3
  • 22
  • 26
  • 3
    installing ``pkg-config`` was the missing unintuitive step for me as well, this when installing ``matplotlib`` in a docker container with ``ubuntu:14.04`` as base-image. – SlimJim Mar 01 '15 at 16:19
  • This also fixed it for me as well on a virtualbox VM. Looks like `pkg-config` is what is needed for virtual machine installations. – Alma Jun 24 '16 at 00:30
7

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
James Mills
  • 18,669
  • 3
  • 49
  • 62
PaulMest
  • 12,925
  • 7
  • 53
  • 50
7

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
thang
  • 3,466
  • 1
  • 19
  • 31
Miae Kim
  • 1,713
  • 19
  • 21
4

On Ubuntu, it worked after I installed blt-dev package.

$sudo apt-get install blt-dev
$pip install matplotlib
Caleb Kiage
  • 1,422
  • 12
  • 17
  • blt-dev needs `apt-get install libfreetype6-dev` to run so it is automaticly installed with blt-dev. – Tristan Jun 24 '16 at 07:15
1

I'm using Mint an none of this answers worked for me, I needed to:

sudo apt-get install build-essential g++
Shapi
  • 5,493
  • 4
  • 28
  • 39
1

I had the same issue with Python 3.6 on Windows, but then I switched to Python 3.5.2 and everything works fine.

klimenkov
  • 347
  • 2
  • 8
0

This command sudo apt-get install libfreetype6-dev failed for me on ubuntu 16.04,
The following packages have unmet dependencies: libfreetype6-dev : Depends: libfreetype6 (= 2.6.1-0.1ubuntu2) but 2.6.1-0.1ubuntu2.3 is to be installed

So I downloaded installed freetype from the source, credit to this guide

$ tar -xvjf freetype-x.y.tar.bz2  # extract the downloaded version file
$ cd freetype-x.y/ 
$ ./configure
$ make
$ sudo make install 

switched to virtualenv and pip install matplotlib and everything is working.

StackEdd
  • 624
  • 1
  • 10
  • 23
0

I followed James Mills' answer to install freetype. But still, although freetype was installed, the program was still failing. I believe this was because the program was not able to find the path of freetype. The following command solved the issue.

sudo apt-get install pkg-config

I found this solution on https://github.com/matplotlib/matplotlib/issues/3029/