I am using Mac OSX 10.8, previously I used macports, but I switched to brew.
Snows-MacBook-Pro:~ Mac$ brew search matplotlib samueljohn/python/matplotlib Snows-MacBook-Pro:~ Mac$ pip search matplotlib matplotlib - Python plotting package
So my question is easy. Should I use brew or pip for installing matplotlib ? Is there any difference and what ?
My goal is to have pandas, ipythone notebook and simpleCV up and running.
I recommend using a package manager (brew, indeed, or MacPorts). Here are a few reasons why:
If you use your package manager (MacPorts, brew,…) to later install additional programs that depend on Matplotlib, the package manager will install it regardless.
If you install a Python package via pip, and pip installs it in your package manager tree (MacPorts, brew,…), the package manager might complain. For example, MacPorts does not want to erase pip-installed packages, as a precaution, so compilation stops when MacPort detects that someone walked on its turf. The best way of installing Python packages is to first check if they are provided by your package manager, and then only install them with pip if they are not.
Compilation with pip sometimes fails where a package manager (MacPorts,…) has no problem: package managers are simply more powerful and general tools (they play nicely with required compiled libraries, for instance).
I would not recommend using a separate distribution of Matplotlib, for the same kind of reasons: any program from brew that depends on Matplotlib will install it anyway. Furthermore, if you instead want to install such a program without your package manager, it is generally hard to make it work with a specific distribution of Matplotlib (they might need libraries to be installed of top of it, etc.).
In summary, I would recommend to use one system for everything (brew, since this is what you chose), and
pip for things that this system does not provide (just make sure that the pip you use corresponds to where you want things to go: your package manager's Python library, with the right version, or the OS-provided Python,…). Multiplying tools and installs is too messy, in my experience, as various distributions/package managers/etc. are usually not meant to play well with each other.
Edit: IMHO virtualenv and virtualenvwrapper have now been largely supplanted by the superb combination of pyenv and pipenv which combine to provide wonderfully isolated python version and dependency management. It makes it worth considering setting up dummy projects even if you want to just play around with various python packages. Dependencies are tracked stably and pipenv includes functionality for checking package updates and security issues. I'd highly recommend a switchover.
Consider managing your python packages in dedicated virtualenvs. You can install any non-python dependencies (freetype which is required by matplotlib) using Homebrew, but you may ultimately have fewer headaches managing your python packages using pip within a virtualenv
If you are using the system python, you can install matplotlib like so. I'm assuming you want to place the virtualenv at top level of your home directory, so the first line in the listing below may be different if you want to create the virtualenv elsewhere and you'll need to adjust the remaining lines accordingly.
cd ~ sudo easy install pip sudo pip install virtualenv brew install pkg-config freetype virtualenv matplotlibenvironment source matplotlibenvironment/bin/activate
/usr/local/include/freetype2 exists but
/usr/local/include/freetype doesn't you will need to create a symlink from freetype2 to freetype to prevent errors when installing the matplotlib package
cd /usr/local/include ln -s freetype2 freetype
Finally, you can install matplotlib using pip. pip install matplotlib
Any applications run from the previously created virtualenv will be able to import matplotlib.
Should you decide to use virtualenvs extensively, you may want to take a look at virtualenvwrapper which provide very nice functionality for managing multiple virtualenvs and switching between them.