Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

freetype cannot be found by build #3029

Closed
kravietz opened this issue May 1, 2014 · 55 comments
Closed

freetype cannot be found by build #3029

kravietz opened this issue May 1, 2014 · 55 comments
Milestone

Comments

@kravietz
Copy link

kravietz commented May 1, 2014

I've tried to install matplotlib using pip on Linux and it couldn't find freetype during the build process, even though it's installed with dev packages.

freetype: no  [The C/C++ header for freetype2 (ft2build.h)
                    could not be found.  You may need to install the
                    development package.]

But:

$ ls -l /usr/include/freetype2/ft2build.h 
-rw-r--r-- 1 root root 2383 Mar 13 17:29 /usr/include/freetype2/ft2build.h

And:

$ freetype-config --cflags
-I/usr/include/freetype2
@tacaswell
Copy link
Member

Can you provide any more details (distribution, version etc)?

@kravietz
Copy link
Author

kravietz commented May 1, 2014

Linux: Ubuntu 14.04 LTS

Libraries:

libfreetype6:amd64 2.5.2-1ubuntu2
libfreetype6-dev 2.5.2-1ubuntu2

Matplotlib matplotlib==1.3.1 (from pip)

I've checked the setupext.py and it looks that for freetype it only checks for the ft2build.h in /usr/include and not in /usr/include/freetype2 even though it's added to list of checked directories for FreeType.

@tacaswell
Copy link
Member

I can not reproduce this in a virtual environment on 14.04.

@kmike
Copy link
Contributor

kmike commented May 2, 2014

It looks similar to #2623. Even if it is not the same issue, are there plans for 1.3.2? :)

@espdev
Copy link

espdev commented May 7, 2014

I have the same problem. I try to install matplotlib in a virtual environment on ubuntu server 14.04. freetype-devel has been installed (package libfreetype6-dev):

esp@ubuntu-srv:~/temp$ locate freetype | grep ft2build.h
/usr/include/freetype2/ft2build.h

But matplotlib does not find it.

@tacaswell
Copy link
Member

@espdev What version of mpl?

@espdev
Copy link

espdev commented May 7, 2014

@tacaswell Version 1.3.1 from PyPI.

@razius
Copy link
Contributor

razius commented May 16, 2014

A temporary fix would be to create a symlink before installing matplotlib using pip.

$ ln -s /usr/include/freetype2/ft2build.h /usr/include/

@tacaswell tacaswell added this to the v1.4.0 milestone May 16, 2014
@steko
Copy link

steko commented May 24, 2014

I found the same issue on Debian unstable with Matplotlib 1.3.1 (both from PyPI and the tag release on github - although I think they're the same).

The fix by @razius at https://github.com/razius/matplotlib/commit/66ee42d194bef1d045918c54cc81a9cb186bd440 works for me and I managed to install matplotlib from source after applying the same patch to setupext.py

@benesch
Copy link

benesch commented May 28, 2014

@kmike agreed, this looks like it's fixed by #2623.

@steko @kravietz @espdev does installing from the 1.3.x branch work?

pip install https://codeload.github.com/matplotlib/matplotlib/tar.gz/v1.3.x

If so, @tacaswell I renew my request for a 1.3.2.

@benesch
Copy link

benesch commented May 28, 2014

Never mind; upon further investigation, this is unrelated to #2623.

This bug only occurs if pkg-config is not installed; a simple

sudo apt-get install pkg-config

will shore up the include paths for now.

@tacaswell
Copy link
Member

Closing this as #3067 is merged into master.

@benesch The issue with 1.3.2 is devs having enough time to produce one. As you can see we are swamped trying to get 1.4.0 out.

@post2web
Copy link

Same here.

sudo apt-get install pkg-config 
did the trick

@gawbul
Copy link

gawbul commented Feb 11, 2015

Same here - pkg-config wasn't installed!

brucellino added a commit to AAROC/invenio that referenced this issue Mar 3, 2015
The pkg-config package needs to be installed, else `pip install -r requirements.txt` will fail when installing matplotlib. See matplotlib/matplotlib#3029 and https://github.com/brucellino/zenodo-docker-role/issues/3
@Altoidnerd
Copy link

Same here... principle error message is

* The following required packages can not be built:

                        * freetype

----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-FyyI8J/matplotlib

I tried

apt-get install pkg-config 

but the command return 0 installed/updated and nevertheless didn't solve my problem.
more discussion:

@llazzaro
Copy link

Same here with OS X 10.10.3

fixed with

brew install pkg-config

@tacaswell
Copy link
Member

@llazzaro This is documented in https://github.com/matplotlib/matplotlib/blob/master/README.osx but says to use brew install pkgconfig instead of brew install pkg-config. Do both work or did brew re-name things under us?

attn @jenshnielsen

@jenshnielsen
Copy link
Member

Both should work. But pkg-config is the correct name and pgkconfig is an alias see https://github.com/Homebrew/homebrew/blob/master/Library/Aliases/pkgconfig

@cchriste
Copy link

sudo apt-get install pkg-config 

worked for me!

@khazamov
Copy link

@benesch thanks for the post - it worked. How did you find out what was the reason?

@benesch
Copy link

benesch commented Aug 25, 2015

@khazamov it's been a year, but IIRC I went source spelunking and noticed the hardcoded path to the freetype header was incorrect for OS X. Luckily pkg-config is capable of detecting freetype, and matplotlib prefers pkg-config's advice over the hardcoded path.

@scott-vsi
Copy link
Contributor

Thanks for the link. If the installation script can't suggest installing pkg-config (if it is not installed) when failing to find freetype then perhaps the documentation could suggest this.

E.g., in the Building on Linux you could add a note like

If the freetype developer package is installed by the system package manager but not found when installing matplotlib, try installing pkg-config, a tool used to find required non-python libraries.

@tacaswell
Copy link
Member

@scott-vsi Can you put in a Pull request adding that text where you would expect to have found it?

@ameyp
Copy link

ameyp commented Mar 2, 2016

@tacaswell I would really prefer having the installation script check for pkg-config instead. I can try to put in a PR for that if you'd like. I believe most users would try to install matplotlib via either pip or the system package manager, encounter the error, google for the error and then end up here. Having the installation check for pkg-config seems like a cleaner solution to me.

@scott-vsi
Copy link
Contributor

I agree that is better. I did a pull request for the interim if you want.

@saukymo
Copy link

saukymo commented Mar 17, 2016

sudo apt-get install pkg-config
works for me

@calebebrim
Copy link

brew install pkgconfig
I'm getting:
Warning: pkg-config-0.28 already installed

But i still can't install matplotlib

More about this issue: http://stackoverflow.com/questions/36341660/python-pip-install-exception-matplotlib

Should I open a new issue ?

@jenshnielsen
Copy link
Member

@calebebrim Did you actually install freetype?

brew install freetype

Freetype is a dependency of matplotlib and needs to be installed for matplotlib to build. pkg-config only helps locate it.

omsai added a commit to omsai/poretools that referenced this issue Jun 11, 2016
- libfreetype6-dev satisfies the freetype requirement.

- pkg-config addresses freetype detection by matplotlib (see
  matplotlib/matplotlib#3029).
@janssen
Copy link

janssen commented Jun 16, 2016

I'm having this problem on Windows 10, building matplotlib 1.5.1 for Python 2.7.11. I'm using the conda package manager. "conda build matplotlib" errors out with

BUILDING MATPLOTLIB
            matplotlib: yes [1.5.1]
                python: yes [2.7.11 |Continuum Analytics, Inc.| (default,
                        Feb 16 2016, 09:58:36) [MSC v.1500 64 bit (AMD64)]]
              platform: yes [win32]

REQUIRED DEPENDENCIES AND EXTENSIONS
                 numpy: yes [version 1.11.0]
              dateutil: yes [using dateutil version 2.5.3]
                  pytz: yes [using pytz version 2016.4]
                cycler: yes [using cycler version 0.10.0]
               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 [using pyparsing version 2.1.4]
                libagg: yes [pkg-config information for 'libagg' could not
                        be found. Using local copy.]
              freetype: no  [The C/C++ header for freetype (ft2build.h)
                        could not be found.  You may need to install the
                        development package.]
                   png: yes [Using unknown version found on system.]
                 qhull: yes [pkg-config information for 'qhull' could not be
                        found. Using local copy.]

OPTIONAL SUBPACKAGES
           sample_data: yes [installing]
              toolkits: yes [installing]
                 tests: yes [nose 0.11.1 or later is required to run the
                        matplotlib test suite. Please install it with pip or
                        your preferred tool to run the test suite / mock is
                        required to run the matplotlib test suite. Please
                        install it with pip or your preferred tool to run
                        the test suite]
        toolkits_tests: yes [nose 0.11.1 or later is required to run the
                        matplotlib test suite. Please install it with pip or
                        your preferred tool to run the test suite / mock is
                        required to run the matplotlib test suite. Please
                        install it with pip or your preferred tool to run
                        the test suite]

OPTIONAL BACKEND EXTENSIONS
                macosx: no  [Mac OS-X only]
                qt5agg: no  [PyQt5 not found]
                qt4agg: no  [PySide not found; PyQt4 not found]
               gtk3agg: no  [Requires pygobject to be installed.]
             gtk3cairo: no  [Requires cairocffi or pycairo to be installed.]
                gtkagg: no  [Requires pygtk]
                 tkagg: no  [The C/C++ header for Tk (tk.h) could not be
                        found.  You may need to install the development
                        package.]
                 wxagg: no  [requires wxPython]
                   gtk: no  [Requires pygtk]
                   agg: yes [installing]
                 cairo: no  [cairocffi or pycairo not found]
             windowing: yes [installing, installing]

OPTIONAL LATEX DEPENDENCIES
                dvipng: no
           ghostscript: no
                 latex: no
               pdftops: no

OPTIONAL PACKAGE DATA
                  dlls: no  [skipping due to configuration]

============================================================================
                        * The following required packages can not be built:
                        * freetype

freetype is installed. ft2build.h is present. There is no pkg-config for Windows. This seems like a real matplotlib config bug that is being covered over by punting to pkg-config. Wish it could be fixed.

@tacaswell
Copy link
Member

@janssen I suggest you send this issue to the user mailing list (matplotlib-users@python.org which will require you to register to post un-moderated) or have a look at our appveyor configuration files (which build mpl in a conda env on windows).

@kubark42
Copy link

Same problem here, sudo apt-get install pkg-config resolved it. It would be very helpful if the build script would either suggest checking pkg-config directly, or would point to this GitHub issue. It would certainly have saved me at least 15 minutes of trial and error before landing here.

@TuringZhu
Copy link

@razius

I run your command by root user but get an error of 'Operation not permitted' on Mac.
And the command 'find / -name ft2build.h' get the flowing result:

/Users/XXXX/Downloads/freetype-2.6/devel/ft2build.h
/Users/XXXX/Downloads/freetype-2.6/include/ft2build.h
/Users/XXXX/Downloads/matplotlib-1.5.1/src/ft2build.h
/usr/local/apps/freetype-2.6/include/freetype2/ft2build.h
/usr/local/include/freetype2/ft2build.h

@cfblaeb
Copy link

cfblaeb commented Jul 19, 2016

Have this issue on ubuntu 16.04, python 3.5.2 (virtualenv), matplotlib 1.5.1 (installed via pip).
ft2build.h is in /usr/include/freetype2/ft2build.h
and sym linking it to /usr/include/ fixes it.
$ ln -s /usr/include/freetype2/ft2build.h /usr/include/

@iacchus
Copy link

iacchus commented Jan 5, 2017

OPTIONAL PACKAGE DATA
                  dlls: no  [skipping due to configuration]

============================================================================
                        * The following required packages can not be built:
                        * freetype

Then

sudo apt-get install libfreetype6-dev
sudo pip install matplotlib --upgrade

DONE

Which, by the way, is exactly the only error that the output is clearly saying.

@OnlyBelter
Copy link

OnlyBelter commented Dec 25, 2017

If you are using docker, and install matplotlib in python:3.5-alpine, add this in your Dockerfile may hlep:

RUN set -e; \
        apk add --no-cache --virtual .build-deps \
                gcc \
                libc-dev \
                linux-headers \
                mariadb-dev \
                python3-dev \
                postgresql-dev \
                freetype-dev \
                libpng-dev \
                libxml2-dev \
                libxslt-dev \
                zlib-dev \
        ;

@z-pc
Copy link

z-pc commented Jan 12, 2018

If you're installing matplotlib in windows.
Then try:

  1. Modify setupext.py:
    1.1 Follow def get_base_dirs():
    1.2. "Try" replace win_bases = ['win32_static', ] -> win_bases = ['C:\Program Files\Anaconda2\Library', ]
  2. Install C++ compiler for Python at link: https://www.microsoft.com/en-us/download/details.aspx?id=44266
    If error about library, you can go to C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include
    "no replace" to C:\Users\Yourname\AppData\Local\Programs\Common\Microsoft\Visual C++ for Python\9.0\VC\include

@stardigits
Copy link

In termux solve by:

pkg install freetype freetype-dev
export CPATH=$PREFIX/include:$PREFIX/include/freetype2:$PREFIX/include/freetype2/freetype
pip3 install matplotlib

@maximlomans
Copy link

maximlomans commented Dec 12, 2019

Downloading https://files.pythonhosted.org/packages/26/04/8b381d5b166508cc258632b225adbafec49bbe69aa9a4fa1f1b461428313/matplotlib-3.0.3.tar.gz (36.6MB)
|¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦| 36.6MB 915kB/s
ERROR: Command errored out with exit status 1:
command: /usr/bin/python3 -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-sp8h0mz6/matplotlib/setup.py'"'"'; file='"'"'/tmp/pip-install-sp8h0mz6/matplotlib/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(file);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, file, '"'"'exec'"'"'))' egg_info --egg-base pip-egg-info
cwd: /tmp/pip-install-sp8h0mz6/matplotlib/
Complete output (47 lines):
============================================================================
Edit setup.cfg to change the build options

BUILDING MATPLOTLIB
            matplotlib: yes [3.0.3]
                python: yes [3.5.3 (default, Sep 27 2018, 17:25:39)  [GCC
                        6.3.0 20170516]]
              platform: yes [linux]

REQUIRED DEPENDENCIES AND EXTENSIONS
                 numpy: yes [version 1.17.2]
      install_requires: yes [handled by setuptools]
                libagg: yes [pkg-config information for 'libagg' could not
                        be found. Using local copy.]
              freetype: no  [The C/C++ header for freetype2 (ft2build.h)
                        could not be found.  You may need to install the
                        development package.]
                   png: no  [pkg-config information for 'libpng' could not
                        be found.]
                 qhull: yes [pkg-config information for 'libqhull' could not
                        be found. Using local copy.]

OPTIONAL SUBPACKAGES
           sample_data: yes [installing]
              toolkits: yes [installing]
                 tests: no  [skipping due to configuration]
        toolkits_tests: no  [skipping due to configuration]

OPTIONAL BACKEND EXTENSIONS
                   agg: yes [installing]
                 tkagg: yes [installing; run-time loading from Python Tcl /
                        Tk]
                macosx: no  [Mac OS-X only]
             windowing: no  [Microsoft Windows only]

OPTIONAL PACKAGE DATA
                  dlls: no  [skipping due to configuration]

============================================================================
                        * The following required packages can not be built:
                        * freetype, png
                        * Try installing freetype with `apt-get install
                        * libfreetype6-dev` and pkg-config with `apt-get
                        * install pkg-config`
                        * Try installing png with `apt-get install
                        * libpng12-dev` and pkg-config with `apt-get install
                        * pkg-config`
----------------------------------------

ERROR: Command erred out with exit status 1: python setup.py egg_info Check the logs for full command output.

on raspbian stretch
sudo apt install libpng12-dev libfreetype6-dev
Reading package lists... Done
Building dependency tree
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

sudo apt install libpng12-0 libpng12-dev libpng-tools libfreetype6-dev
sudo apt install libxslt libxml2 libxml2-dev python3-libxml2 python3-libxml2-dbg python3-lxml python3-lxml-dbg python3-testscenarios python3-jsonschema

*not yet done yet pip3 still glitching installing pymzq & kiwisolver

@tacaswell
Copy link
Member

@marxenegls Can you open a topic at https://discourse.matplotlib.org/c/community/install for installing Matplotlib on rasbian?

@liuqinfei
Copy link

I also encountered this problem in openEuler release 20.03 (LTS-SP1).
Package freetype-2.10.2-2.oe1.aarch64 is already installed.
After searching, I found that the problem can be solved by performing the following operations:
dnf install freetype-devel.aarch64 -y --nogpgcheck

@JakeColor
Copy link

Summarizing my experience + solution in case it helps anyone...

I encountered this error while pip installing matplotlib from a requirements.txt in a Docker image. In particular, I requested a specific older version of matplotlib (3.4.3) while also simultaneously installing/requesting the most recent version of Python (3.10), torch, etc.

Turns out pip will attempt to compile a packages on its own if it can't find a pre-compiled version in the public repositories. In my case, the slim Docker image didn't have the build tools necessary for pip to compile -> the freetype error.

The solution was simple: update the version of matplotlib i was requesting to one available pre-compiled.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests