The Computer Oracle

How to install matplotlib on OS X?

--------------------------------------------------
Hire the world's top talent on demand or became one of them at Toptal: https://topt.al/25cXVn
and get $2,000 discount on your first invoice
--------------------------------------------------

Take control of your privacy with Proton's trusted, Swiss-based, secure services.
Choose what you need and safeguard your digital life:
Mail: https://go.getproton.me/SH1CU
VPN: https://go.getproton.me/SH1DI
Password Manager: https://go.getproton.me/SH1DJ
Drive: https://go.getproton.me/SH1CT


Music by Eric Matyas
https://www.soundimage.org
Track title: Puzzle Game 5 Looping

--

Chapters
00:00 How To Install Matplotlib On Os X?
01:20 Accepted Answer Score 12
01:33 Answer 2 Score 17
01:51 Answer 3 Score 3
02:18 Answer 4 Score 3
02:43 Thank you

--

Full question
https://superuser.com/questions/242190/h...

--

Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...

--

Tags
#macos #python #homebrew

#avk47



ANSWER 1

Score 17


The problem is that when the C extensions are compiled, required headers files aren't in the search path, and when they're being linked, shared libraries aren't in the search path either.

The following worked for me:

export LDFLAGS="-L/usr/X11/lib"
export CFLAGS="-I/usr/X11/include -I/usr/X11/include/freetype2 -I/usr/X11/include/libpng12"
pip install matplotlib-1.0.1.tar.gz



ACCEPTED ANSWER

Score 12


The simple answer is: You need to have pkg-info installed or else setup.py won't be able to find installed libraries.




ANSWER 3

Score 3


I followed this page's instructions. I got stuck at

pip install -e git+https://github.com/matplotlib/matplotlib#egg=matplotlib-dev

Then I did:

git clone https://github.com/matplotlib/matplotlib.git
cd matplotlib
python setup.py build
python setup.py install

Checked my installation by typing in terminal:

python
import matplotlib
print matplotlib.__version__
print matplotlib.__file__

I got version 1.1.0 (as of this writing) and path /usr/local/Cellar/...




ANSWER 4

Score 3


Altneratively, you could use MacPorts or Fink. With MacPorts this would be

sudo port install py27-matplotlib

which resolves the dependencies automatically.

Personally I used Macports to install python2.7 with matplotlib and it seems to works fine on 10.7. Fink is in the process of upgrading their internals to work with the new 10.7 build system.