installing matplotlib on mac os X with the *.dmg file

Hi,

I’m having trouble installing matplotlib on mac os x. I downloaded the dmg file (matplotlib-1.1.1-py2.7-python.org-macosx10.6.dmg) from http://sourceforge.net/projects/matplotlib/files/matplotlib/matplotlib-1.1.1/ . I was able to install this package. Beforehand, I installed python from python.org (I read about the need to do this rather than use the shipped python for mac os x). So, the original python is in /usr/bin/python and the other, newer one, is in /usr/local/bin/python.

However, after running “ipython -pylab”, I get an error message:

Python 2.7.1 (r271:86832, Aug 5 2011, 03:30:24)

Type “copyright”, “credits” or “license” for more information.

IPython 0.13 – An enhanced Interactive Python.

? -> Introduction and overview of IPython’s features.

%quickref -> Quick reference.

help -> Python’s own help system.

object? -> Details about ‘object’, use ‘object??’ for extra details.

[TerminalIPythonApp] GUI event loop or pylab initialization failed

···

ImportError Traceback (most recent call last)

/Library/Python/2.7/site-packages/ipython-0.13-py2.7.egg/IPython/core/pylabtools.pyc in find_gui_and_backend(gui)

194     """

195 

–> 196 import matplotlib

197 

198     if gui and gui != 'auto':

ImportError: No module named matplotlib

It seems that I don’t have a module-- but I just installed it?

Side note: I’ve read to the best of my ability this page here, http://matplotlib.sourceforge.net/faq/installing_faq.html#os-x-notes , but there seems to be a disconnect on this page between the actual installation procedure. For example, no where on this page does it mention about a *.dmg file, yet the sourceforge site has the *.dmg file. And this help site mentions *.zip files, but this time the sourceforge download page does not have any *.zip files! What is going on here?

Thanks,

Tim

I can't comment on specifics, but things to watch out for:
1) Native Mac OS X's python vs python.org's python (the latter is preferred)
2) Numpy and other dependancies

Personally, I've had the best luck with the approach laid out here:
http://www.thisisthegreenroom.com/2011/installing-python-numpy-scipy-matplotlib-and-ipython-on-lion/

Best of luck,
-paul

···

On Fri, Aug 17, 2012 at 2:30 PM, Timothy Duly <timduly4@...287...> wrote:

Hi,

I'm having trouble installing matplotlib on mac os x. I downloaded the dmg
file (matplotlib-1.1.1-py2.7-python.org-macosx10.6.dmg) from
http://sourceforge.net/projects/matplotlib/files/matplotlib/matplotlib-1.1.1/
. I was able to install this package. Beforehand, I installed python from
python.org (I read about the need to do this rather than use the shipped
python for mac os x). So, the original python is in /usr/bin/python and the
other, newer one, is in /usr/local/bin/python.

However, after running "ipython -pylab", I get an error message:

Python 2.7.1 (r271:86832, Aug 5 2011, 03:30:24)
Type "copyright", "credits" or "license" for more information.

IPython 0.13 -- An enhanced Interactive Python.
? -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help -> Python's own help system.
object? -> Details about 'object', use 'object??' for extra details.
[TerminalIPythonApp] GUI event loop or pylab initialization failed
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
/Library/Python/2.7/site-packages/ipython-0.13-py2.7.egg/IPython/core/pylabtools.pyc
in find_gui_and_backend(gui)
    194 """
    195
--> 196 import matplotlib
    197
    198 if gui and gui != 'auto':

ImportError: No module named matplotlib

It seems that I don't have a module-- but I just installed it?

Side note: I've read to the best of my ability this page here,
http://matplotlib.sourceforge.net/faq/installing_faq.html#os-x-notes , but
there seems to be a disconnect on this page between the actual installation
procedure. For example, no where on this page does it mention about a *.dmg
file, yet the sourceforge site has the *.dmg file. And this help site
mentions *.zip files, but this time the sourceforge download page does not
have any *.zip files! What is going on here?

Thanks,
Tim

The dmg you are referring to appears to install to /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages (The main library, not the one for in our user directory). Most likely, this directory is not in pythons search path. Therefore, python can’t find any modules installed there. To verify this, first check, whether this directory exists. Then start ipython and enter:

from sys import path

path

Path is a list of all paths which are searched for installed modules. If my suspicion is correct, the directory where you installed matplotlib is not in the list. You can just add it

path.append(’/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages’)

and then import matplotlib. However, you have add it to your path again every time you start a new session. To add it permanently, put an otherwise empty text file which includes the path and place it in one of the directories that are already on the search path. You have add a .pth suffix to this text file when you save it.

Best,

Felix

ps: There are many ways to install python and packages and all are more complicated to what you are used to from the mac - welcome to the world of unix / linux software… Still, I have been successful using either macports (slow, but reliable) as well as distribute and pip. I recommend macports which creates a new installation for everything you want / need in /opt. It can also install all of the ipython optional dependencies like the qtconsole and the notebook which cannot be done using pure python package managers.

···

Am 17.08.2012 um 23:30 schrieb Timothy Duly:

Hi,

I’m having trouble installing matplotlib on mac os x. I downloaded the dmg file (matplotlib-1.1.1-py2.7-python.org-macosx10.6.dmg) from http://sourceforge.net/projects/matplotlib/files/matplotlib/matplotlib-1.1.1/ . I was able to install this package. Beforehand, I installed python from python.org (I read about the need to do this rather than use the shipped python for mac os x). So, the original python is in /usr/bin/python and the other, newer one, is in /usr/local/bin/python.

However, after running “ipython -pylab”, I get an error message:

Python 2.7.1 (r271:86832, Aug 5 2011, 03:30:24)

Type “copyright”, “credits” or “license” for more information.

IPython 0.13 – An enhanced Interactive Python.

? -> Introduction and overview of IPython’s features.

%quickref -> Quick reference.

help -> Python’s own help system.

object? -> Details about ‘object’, use ‘object??’ for extra details.

[TerminalIPythonApp] GUI event loop or pylab initialization failed


ImportError Traceback (most recent call last)

/Library/Python/2.7/site-packages/ipython-0.13-py2.7.egg/IPython/core/pylabtools.pyc in find_gui_and_backend(gui)

194     """
195 

–> 196 import matplotlib

197 
198     if gui and gui != 'auto':

ImportError: No module named matplotlib

It seems that I don’t have a module-- but I just installed it?

Side note: I’ve read to the best of my ability this page here, http://matplotlib.sourceforge.net/faq/installing_faq.html#os-x-notes , but there seems to be a disconnect on this page between the actual installation procedure. For example, no where on this page does it mention about a *.dmg file, yet the sourceforge site has the *.dmg file. And this help site mentions *.zip files, but this time the sourceforge download page does not have any *.zip files! What is going on here?

Thanks,

Tim


Live Security Virtual Conference
Exclusive live event will cover all the ways today’s security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Thank you for the information Paul and Felix.

I have followed your advice and installed a package manager, pip. However, running:

sudo pip install matplotlib

did not work. Instead, the key was:

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

worked well, although I’m not sure why.

For archival purposes, I have pasted my notes below for installing python / matplotlib on mac os x.

Thanks again,

Tim

First had to install homebrew (http://mxcl.github.com/homebrew/), ran “brew doctor” and fixed the appropriate warning messages. Had to add “export PATH=/usr/local/bin:$PATH” under ~/.bash_profile. Also had to install Xcode from app store, and download “Developer Tools” under Settings–>Downloads.

brew doctor

brew update

Then ran “brew install python”, but this didnt work. So i installed gfortran instead:

brew install gfortran

then installed python from python.org. Because I changed the path in the .bash_profile, this version of python was “first” when I called python. (“which python” should yield /usr/local/bin/python, and “python --version” should give 2.7.2)

i also used homebrew to install “pip”, a python module manager, and gfortran:

brew install pip

brew install gfortran

with pip, you can install PIL, scipy, (and nump):

sudo pip install pil

sudo pip install scipy

sudo pip install numpy

(but be sure you have gfortran before these)

to get matplotlib, instead of:

sudo pip install matplotlib

do:

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

this will make “ipython --pylab” work correctly

Also: I had to install the 32 bit version of python-- not sure if 64/32 bit works… Doesn’t matter which version you download

To remove python (from here),

  1. remove /Applications/Python 2.x
  2. remove the framework folder: /Library/Frameworks/Python.framework
  3. you can remove the symbolic link too,…

To remove matplotlib, here

···

On Fri, Aug 17, 2012 at 5:09 PM, Felix Patzelt <felix@…4098…> wrote:

The dmg you are referring to appears to install to /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages (The main library, not the one for in our user directory). Most likely, this directory is not in pythons search path. Therefore, python can’t find any modules installed there. To verify this, first check, whether this directory exists. Then start ipython and enter:

from sys import path

path

Path is a list of all paths which are searched for installed modules. If my suspicion is correct, the directory where you installed matplotlib is not in the list. You can just add it

path.append(’/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages’)

and then import matplotlib. However, you have add it to your path again every time you start a new session. To add it permanently, put an otherwise empty text file which includes the path and place it in one of the directories that are already on the search path. You have add a .pth suffix to this text file when you save it.

Best,

Felix

ps: There are many ways to install python and packages and all are more complicated to what you are used to from the mac - welcome to the world of unix / linux software… Still, I have been successful using either macports (slow, but reliable) as well as distribute and pip. I recommend macports which creates a new installation for everything you want / need in /opt. It can also install all of the ipython optional dependencies like the qtconsole and the notebook which cannot be done using pure python package managers.

Am 17.08.2012 um 23:30 schrieb Timothy Duly:

Hi,

I’m having trouble installing matplotlib on mac os x. I downloaded the dmg file (matplotlib-1.1.1-py2.7-python.org-macosx10.6.dmg) from http://sourceforge.net/projects/matplotlib/files/matplotlib/matplotlib-1.1.1/ . I was able to install this package. Beforehand, I installed python from python.org (I read about the need to do this rather than use the shipped python for mac os x). So, the original python is in /usr/bin/python and the other, newer one, is in /usr/local/bin/python.

However, after running “ipython -pylab”, I get an error message:

Python 2.7.1 (r271:86832, Aug 5 2011, 03:30:24)

Type “copyright”, “credits” or “license” for more information.

IPython 0.13 – An enhanced Interactive Python.

? -> Introduction and overview of IPython’s features.

%quickref -> Quick reference.

help -> Python’s own help system.

object? -> Details about ‘object’, use ‘object??’ for extra details.

[TerminalIPythonApp] GUI event loop or pylab initialization failed


ImportError Traceback (most recent call last)

/Library/Python/2.7/site-packages/ipython-0.13-py2.7.egg/IPython/core/pylabtools.pyc in find_gui_and_backend(gui)

194     """
195 

–> 196 import matplotlib

197 
198     if gui and gui != 'auto':

ImportError: No module named matplotlib

It seems that I don’t have a module-- but I just installed it?

Side note: I’ve read to the best of my ability this page here, http://matplotlib.sourceforge.net/faq/installing_faq.html#os-x-notes , but there seems to be a disconnect on this page between the actual installation procedure. For example, no where on this page does it mention about a *.dmg file, yet the sourceforge site has the *.dmg file. And this help site mentions *.zip files, but this time the sourceforge download page does not have any *.zip files! What is going on here?

Thanks,

Tim


Live Security Virtual Conference
Exclusive live event will cover all the ways today’s security and
threat landscape has changed and how IT managers can respond. Discussions

will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/_______________________________________________

Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users