Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Installing MatplotLib in mac osx lion

I was trying to install matplotlib in Mac OSX Lion. Tried to used the binary that is in the sourcefourge site, but I got this error: "matplotlib requires System Python 2.7 to install".

I went to the Terminal and typed python --version and its check the requirements.

After this I tried to used the pip, and while doing so é got the following error:

"src/_image.cpp:908: error: invalid use of incomplete type ‘struct png_info_def’"

Can you give me clues in how to install it?

Many thanks.

EDIT: I found a way, without having to install a new version of python:

http://the.taoofmac.com/space/blog/2011/07/24/2222

like image 732
nunolourenco Avatar asked Jul 23 '11 12:07

nunolourenco


People also ask

Can you pip install matplotlib?

Matplotlib can be installed using pip. The following command is run in the command prompt to install Matplotlib. This command will start downloading and installing packages related to the matplotlib library. Once done, the message of successful installation will be displayed.

How do I download matplotlib in terminal?

If you are using the Python version that comes with your Linux distribution, you can install Matplotlib via your package manager, e.g.: Debian / Ubuntu: sudo apt-get install python3-matplotlib. Fedora: sudo dnf install python3-matplotlib. Red Hat: sudo yum install python3-matplotlib.

Does Python 3.8 support matplotlib?

matplotlib has released the suitable version for python 3.8.


2 Answers

This is because of a change in the API for libpng v1.5 (which is included with Mac OSX Lion). The changes has already been pushed upstream, so you will need to compile from the upstream repository until the next release.

You can follow the instructions on http://jholewinski.wordpress.com/2011/07/21/installing-matplotlib-on-os-x-10-7-with-homebrew/

like image 83
Prashanth Avatar answered Oct 13 '22 01:10

Prashanth


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 0.10.0 dev (as of this writing) and path /usr/local/Cellar/...

like image 27
David Xia Avatar answered Oct 13 '22 00:10

David Xia