`Sudo pip install matplotlib` fails to find freetype headers. [OS X Mavericks / 10.9] [closed]

2024/11/19 9:22:52

I already have matplotlib-1.2.1 installed as well as numpy-1.8.0. Note - I am using system python with homebrew installed - I have $PYTHONPATH set so Python loads from /Library/Python/x.y/site-packages (where pip installs to).

Here is the code for installing matplotlib (the configurations)

BUILDING MATPLOTLIBmatplotlib: yes [1.3.1]python: yes [2.7.5 (default, Aug 25 2013, 00:04:04)  [GCC4.2.1 Compatible Apple LLVM 5.0 (clang-500.0.68)]]platform: yes [darwin]REQUIRED DEPENDENCIES AND EXTENSIONSnumpy: yes [version 1.8.0]dateutil: yes [using dateutil version 1.5]tornado: yes [tornado was not found. It is required for theWebAgg backend. pip/easy_install may attempt toinstall it after matplotlib.]pyparsing: yes [pyparsing was not found. It is required formathtext support. pip/easy_install may attempt toinstall it after matplotlib.]pycxx: yes [Couldn't import.  Using local copy.]libagg: yes [pkg-config information for 'libagg' could notbe found. Using local copy.]freetype: yes [version 17.1.11]png: yes [version 1.5.17]OPTIONAL SUBPACKAGESsample_data: yes [installing]toolkits: yes [installing]tests: yes [nose 0.11.1 or later is required to run thematplotlib test suite]OPTIONAL BACKEND EXTENSIONSmacosx: yes [installing, darwin]qt4agg: no  [PyQt4 not found]gtk3agg: no  [Requires pygobject to be installed.]gtk3cairo: no  [Requires cairo to be installed.]gtkagg: no  [Requires pygtk]tkagg: yes [installing, version 81008]wxagg: no  [requires wxPython]gtk: no  [Requires pygtk]agg: yes [installing]cairo: no  [cairo not found]windowing: no  [Microsoft Windows only]OPTIONAL LATEX DEPENDENCIESdvipng: yes [version 1.14]ghostscript: yes [version 9.02]latex: yes [version 3.1415926]pdftops: no

And then later down the line, after copying and building files, it gets to build_ext and fails because of missing header files.

running build_ext
building 'matplotlib.ft2font' extension
creating build/temp.macosx-10.9-intel-2.7
creating build/temp.macosx-10.9-intel-2.7/src
creating build/temp.macosx-10.9-intel-2.7/CXX
cc -fno-strict-aliasing -fno-common -dynamic -arch x86_64 -arch i386 -g -Os -pipe -fno-common -fno-strict-aliasing -fwrapv -mno-fused-madd -DENABLE_DTRACE -DMACOSX -DNDEBUG -Wall -Wshorten-64-to-32 -DNDEBUG -g -fwrapv -Os -Wall -Wstrict-prototypes -DENABLE_DTRACE -arch x86_64 -arch i386 -pipe -DPY_ARRAY_UNIQUE_SYMBOL=MPL_matplotlib_ft2font_ARRAY_API -DPYCXX_ISO_CPP_LIB=1 -I/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/numpy/core/include -I/usr/local/include -I/usr/include -I/usr/X11/include -I. -I/usr/local/Cellar/freetype/2.5.2/include/freetype2 -I/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c src/ft2font.cpp -o build/temp.macosx-10.9-intel-2.7/src/ft2font.oclang: warning: argument unused during compilation: '-mno-fused-madd'
In file included from src/ft2font.cpp:3:
In file included from src/ft2font.h:6:
In file included from ./CXX/Extensions.hxx:40:
In file included from ./CXX/Python2/Extensions.hxx:52:
./CXX/Python2/Objects.hxx:1133:23: warning: implicit conversion of NULL constant to 'int' [-Wnull-conversion], offset( NULL )~ ^~~~0In file included from src/ft2font.cpp:3:
In file included from src/ft2font.h:16:
/usr/X11/include/ft2build.h:56:10: fatal error: 'freetype/config/ftheader.h' file not found
#include <freetype/config/ftheader.h>^
1 warning and 1 error generated.error: command 'cc' failed with exit status 1
----------------------------------------Rolling back uninstall of matplotlibReplacing /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/matplotlib-1.1.1-py2.7.egg-info
Cleaning up...Removing temporary dir /private/tmp/pip_build_root...
Command /usr/bin/python -c "import setuptools;__file__='/private/tmp/pip_build_root/matplotlib/setup.py';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-vHUPhA-record/install-record.txt --single-version-externally-managed failed with error code 1 in /private/tmp/pip_build_root/matplotlib
Exception information:
Traceback (most recent call last):File "/Library/Python/2.7/site-packages/pip-1.4.1-py2.7.egg/pip/basecommand.py", line 134, in mainstatus = self.run(options, args)File "/Library/Python/2.7/site-packages/pip-1.4.1-py2.7.egg/pip/commands/install.py", line 241, in runrequirement_set.install(install_options, global_options, root=options.root_path)File "/Library/Python/2.7/site-packages/pip-1.4.1-py2.7.egg/pip/req.py", line 1298, in installrequirement.install(install_options, global_options, *args, **kwargs)File "/Library/Python/2.7/site-packages/pip-1.4.1-py2.7.egg/pip/req.py", line 625, in installcwd=self.source_dir, filter_stdout=self._filter_install, show_stdout=False)File "/Library/Python/2.7/site-packages/pip-1.4.1-py2.7.egg/pip/util.py", line 670, in call_subprocess% (command_desc, proc.returncode, cwd))
InstallationError: Command /usr/bin/python -c "import setuptools;__file__='/private/tmp/pip_build_root/matplotlib/setup.py';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-vHUPhA-record/install-record.txt --single-version-externally-managed failed with error code 1 in /private/tmp/pip_build_root/matplotlib
Answer

I had the same problem, and finally found the solution by checking the compilation commands. It's really simple:

ln -s /usr/local/opt/freetype/include/freetype2 /usr/local/include/freetype
https://en.xdnf.cn/q/26456.html

Related Q&A

Parallel processing from a command queue on Linux (bash, python, ruby... whatever)

I have a list/queue of 200 commands that I need to run in a shell on a Linux server. I only want to have a maximum of 10 processes running (from the queue) at once. Some processes will take a few secon…

How do I select and store columns greater than a number in pandas? [duplicate]

This question already has answers here:How do I select rows from a DataFrame based on column values?(17 answers)Closed 28 days ago.I have a pandas DataFrame with a column of integers. I want the rows …

Plotting transparent histogram with non transparent edge

I am plotting a histogram, and I have three datasets which I want to plot together, each one with different colours and linetype (dashed, dotted, etc). I am also giving some transparency, in order to s…

Cross-platform desktop notifier in Python

I am looking for Growl-like, Windows balloon-tip-like notifications library in Python. Imagine writing code like:>>> import desktopnotifier as dn >>> dn.notify(Title, Long description…

set object is not JSON serializable [duplicate]

This question already has answers here:How to JSON serialize sets? [duplicate](12 answers)Closed 9 years ago.When I try to run the following code:import jsond = {testing: {1, 2, 3}} json_string = json…

Python Sqlite3: INSERT INTO table VALUE(dictionary goes here)

I would like to use a dictionary to insert values into a table, how would I do this? import sqlite3db = sqlite3.connect(local.db) cur = db.cursor()cur.execute(DROP TABLE IF EXISTS Media)cur.execute(CR…

Count the uppercase letters in a string with Python

I am trying to figure out how I can count the uppercase letters in a string. I have only been able to count lowercase letters:def n_lower_chars(string):return sum(map(str.islower, string))Example of w…

Multithreading for Python Django

Some functions should run asynchronously on the web server. Sending emails or data post-processing are typical use cases.What is the best (or most pythonic) way write a decorator function to run a func…

run a crontab job using an anaconda env

I want to have a cron job execute a python script using an already existing anaconda python environment called my_env. The only thing I can think to do is have the cron job run a script called my_scri…

pandas - Merging on string columns not working (bug?)

Im trying to do a simple merge between two dataframes. These come from two different SQL tables, where the joining keys are strings:>>> df1.col1.dtype dtype(O) >>> df2.col2.dtype dtyp…