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 · 53 comments
Closed

freetype cannot be found by build #3029

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

Comments

@kravietz
Copy link

@kravietz 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

@tacaswell tacaswell commented May 1, 2014

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

@kravietz
Copy link
Author

@kravietz 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

@tacaswell tacaswell commented May 1, 2014

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

@kmike
Copy link
Contributor

@kmike 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 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

@tacaswell tacaswell commented May 7, 2014

@espdev What version of mpl?

@espdev
Copy link

@espdev espdev commented May 7, 2014

@tacaswell Version 1.3.1 from PyPI.

@razius
Copy link
Contributor

@razius 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 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 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 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

@tacaswell tacaswell commented May 29, 2014

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

@post2web post2web commented Nov 27, 2014

Same here.

sudo apt-get install pkg-config 
did the trick
@gawbul
Copy link

@gawbul 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

@Altoidnerd Altoidnerd commented Mar 7, 2015

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

@llazzaro llazzaro commented May 16, 2015

Same here with OS X 10.10.3

fixed with

brew install pkg-config
@tacaswell
Copy link
Member

@tacaswell tacaswell commented May 24, 2015

@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

@jenshnielsen jenshnielsen commented May 24, 2015

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

@cchriste cchriste commented Jul 15, 2015

sudo apt-get install pkg-config 

worked for me!

@khazamov
Copy link

@khazamov khazamov commented Aug 21, 2015

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

@benesch
Copy link

@benesch 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.

@ameyp
Copy link

@ameyp ameyp commented Mar 2, 2016

@tacaswell Does the installation work on most systems without pkg-config installed? The headers are at the location specified in the dpkg package, so I wouldn't exactly say that they're in a non-standard location.

@tacaswell
Copy link
Member

@tacaswell tacaswell commented Mar 2, 2016

Not sure. We have talked about moving pkg-config to the required section.

@scott-vsi
Copy link
Contributor

@scott-vsi scott-vsi commented Mar 2, 2016

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

@tacaswell tacaswell commented Mar 2, 2016

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

@ameyp
Copy link

@ameyp 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

@scott-vsi scott-vsi commented Mar 2, 2016

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

@saukymo
Copy link

@saukymo saukymo commented Mar 17, 2016

sudo apt-get install pkg-config
works for me

@calebebrim
Copy link

@calebebrim calebebrim commented Apr 1, 2016

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

@jenshnielsen jenshnielsen commented Apr 1, 2016

@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 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

@tacaswell tacaswell commented Jun 17, 2016

@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

@kubark42 kubark42 commented Jun 24, 2016

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.

@Turing-Chu
Copy link

@Turing-Chu Turing-Chu commented Jul 4, 2016

@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 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/

@feikname feikname mentioned this issue Dec 11, 2016
1 of 1 task complete
@iacchus
Copy link

@iacchus 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 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 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
probonopd added a commit to probonopd/coolreader that referenced this issue May 12, 2019
probonopd added a commit to probonopd/coolreader that referenced this issue May 12, 2019
@stardigits
Copy link

@stardigits stardigits commented Jul 23, 2019

In termux solve by:

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

@marxenegls marxenegls 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

@tacaswell tacaswell commented Dec 12, 2019

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

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

Successfully merging a pull request may close this issue.

None yet
You can’t perform that action at this time.