Skip to content

Pip install can't find freetype and png despite them being installed #15155

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

Closed
oliversheridanmethven opened this issue Aug 29, 2019 · 6 comments
Labels
Milestone

Comments

@oliversheridanmethven
Copy link

I have a virtual environment on a new device for Python2.7. I want to install matplotlib, but it is throwing me the following error:

(venv2.7) osm:~$ pip install matplotlib 
DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 won't be maintained after that date. A future version of pip will drop support for Python 2.7. More details about Python 2 support in pip, can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support
Collecting matplotlib
  Using cached https://files.pythonhosted.org/packages/1e/20/2032ad99f0dfe0f60970941af36e8d0942d3713f442bb3df37ac35d67358/matplotlib-2.2.4.tar.gz
    ERROR: Command errored out with exit status 1:
     command: /home/osm/venv2.7/bin/python2.7 -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-v0wvdH/matplotlib/setup.py'"'"'; __file__='"'"'/tmp/pip-install-v0wvdH/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-v0wvdH/matplotlib/
    Complete output (62 lines):
    ============================================================================
    Edit setup.cfg to change the build options
    
    BUILDING MATPLOTLIB
                matplotlib: yes [2.2.4]
                    python: yes [2.7.15+ (default, Nov 27 2018, 23:36:35)  [GCC
                            7.3.0]]
                  platform: yes [linux2]
    
    REQUIRED DEPENDENCIES AND EXTENSIONS
                     numpy: yes [version 1.16.5]
          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  [The C/C++ header for libpng (png.h) could not
                            be found.  You may need to install the development
                            package.]
                     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
                    macosx: no  [Mac OS-X only]
                    qt5agg: no  [PySide2 not found; 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: yes [installing; run-time loading from Python Tcl /
                            Tk]
                     wxagg: no  [requires wxPython]
                       gtk: no  [Requires pygtk]
                       agg: yes [installing]
                     cairo: no  [cairocffi or pycairo not found]
                 windowing: no  [Microsoft Windows only]
    
    OPTIONAL LATEX DEPENDENCIES
                    dvipng: no
               ghostscript: yes [version 9.26]
                     latex: no
                   pdftops: yes [version 0.62.0]
    
    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 errored out with exit status 1: python setup.py egg_info Check the logs for full command output.

However, considering the png.h file, I know that the header file is in my path, as

(venv2.7) osm:~$ echo $CPATH
/home/osm/.local/include:
(venv2.7) osm:~$ echo $C_INCLUDE_PATH
/home/osm/.local/include:

and

(venv2.7) osm:~$ tree /home/osm/.local/include/ -L 1
/home/osm/.local/include/
├── freetype2
├── gsl
├── libpng16
├── ncurses
├── pngconf.h -> libpng16/pngconf.h
├── png.h -> libpng16/png.h
└── pnglibconf.h -> libpng16/pnglibconf.h

I have just done local installs from source for both freetype and png and so I have no idea why it can't find the headers for these.

I know this problem is similar to
#12169

@anntzer
Copy link
Contributor

anntzer commented Aug 29, 2019

Looks likely due to the bug fixed in #13064, i.e. matplotlib tries to check for headers but doesn't know about $CPATH/$C_INCLUDE_PATH. Probably you can fiddle with the MPLBASEDIRLIST environment variable, or try to backport that PR to 2.2.x (likely a lot of work).

@oliversheridanmethven
Copy link
Author

Is this then a problem with pip or matplot lib?

Do you expect I could build matplotlib using either
python setup.py install -flag_for_local_venv
or build from source with a
'./configure --prefix=/home/osm/.local; make; make install`

@tacaswell tacaswell added this to the v2.2.5 milestone Aug 29, 2019
@tacaswell
Copy link
Member

Why is pip picking the tarball over the wheel?

@oliversheridanmethven
Copy link
Author

oliversheridanmethven commented Aug 29, 2019 via email

@anntzer
Copy link
Contributor

anntzer commented Aug 29, 2019

Do you expect I could build matplotlib using either
python setup.py install -flag_for_local_venv
or build from source with a
'./configure --prefix=/home/osm/.local; make; make install`

MPLBASEDIRLIST effectively plays the role of --prefix. The gory details are in #9737 and #13064; you'll need to experiment with how to set it effectively in your case.

@tacaswell
Copy link
Member

I am going to close this as no-action due to inactivity.

@oliversheridanmethven If you still have this issue a mpl3.x please open a new issue.

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

No branches or pull requests

3 participants