problem importing pyplot/pylab on mac os x 10.4.11

Hi,

I'm having trouble getting pyplot and pylab to work on my Mac v.10.4.11
(Tiger). I've tried searching in both google and different macusers
forums, but haven't found an answer to my problems. If I have overlooked a
webpage please send me a link to the solution.

To download matplotlib I have downloaded the dmg package from the official
matplotlib page
http://sourceforge.net/projects/matplotlib/files/matplotlib/matplotlib-1.0/http://sourceforge.net/projects/matplotlib/files/matplotlib/matplotlib-1.0/

and it seems to install fine. However, I cannot use neither pyplot nor
pylab:

[kariannelap:~] karianne% python
Python 2.5.2 (r252:60911, Feb 22 2008, 07:57:53)
[GCC 4.0.1 (Apple Computer, Inc. build 5363)] on darwin
Type "help", "copyright", "credits" or "license" for more information.

import matplotlib as mpl
import mpl.pyplot

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named mpl.pyplot

import mpl.pylab

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named mpl.pylab

import pylab

Bus error

I tried the clean rebuild and reinstall described on this page:

http://matplotlib.sourceforge.net/faq/installing_faq.html#cleanly-rebuild-and-reinstall-everything

and re-installed without any change. So then I tried deleting all
matplotlib and pylab files and dirs and re-installed, again without
results. I also tried this installation method without success

easy_install matplotlib
Processing matplotlib
error: Not a recognized archive type: matplotlib

Some more info:

[kariannelap:~] karianne% uname -a
Darwin karianneholhjem.local 8.11.1 Darwin Kernel Version 8.11.1: Wed Oct 10 18:23:28 PDT 2007; root:xnu
-792.25.20~1/RELEASE_I386 i386 i386

[kariannelap:~] karianne% python -c 'import matplotlib; print
matplotlib.__version__'
1.0.0

Regarding the matplotlibrc file I have tried both the default
backend : TkAgg
as well as
backend : WxAgg
since some webpages indicated that might be a problem.

Finally, I wrote a little script called bla.py

import matplotlib as mpl
import mpl.pyplot
import mpl.pylab

and ran it

[kariannelap:~] karianne% python bla.py --verbose-helpful
$HOME=/Users/karianne
CONFIGDIR=/Users/karianne/.matplotlib
matplotlib data path
/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/matpl
otlib/mpl-data
loaded rc file
/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/matplotlib/
mpl-data/matplotlibrc
matplotlib version 1.0.0
verbose.level helpful
interactive is False
units is False
platform is darwin
Traceback (most recent call last):
  File "bla.py", line 2, in <module>
    import mpl.pyplot
ImportError: No module named mpl.pyplot

When commenting out line 2 in the scrip this is the output I got:
$HOME=/Users/karianne
CONFIGDIR=/Users/karianne/.matplotlib
matplotlib data path
/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/matpl
otlib/mpl-data
loaded rc file
/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/matplotlib/
mpl-data/matplotlibrc
matplotlib version 1.0.0
verbose.level helpful
interactive is False
units is False
platform is darwin
Traceback (most recent call last):
  File "bla.py", line 3, in <module>
    import mpl.pylab
ImportError: No module named mpl.pylab

Can someone please tell me what I am doing wrong or which files I should
delete to make this work? I have had bad experiences with fink so I prefer
not using it.

cheers,
Karianne

You're on the right track with the debugging information you are
trying to provide. One problem is in your script bla.py. You do

  import matplotlib as mpl
  import mpl.pyplot
  import mpl.pylab

but you need to do

  import matplotlib as mpl
  import matplotlib.pyplot
  import matplotlib.pylab

This won't fix your segfault, but it may help you get get better
debugging information.

My first guess is a numpy version conflict -- what version are you
running? You can check the version requirements of the OSX installer
in the README that is provides. Many recent versions of numpy are not
ABI compatible, unfortunately.

JDH

···

On Thu, Jul 8, 2010 at 5:50 AM, Karianne Holhjem <karianne@...1721...> wrote:

Hi,

I'm having trouble getting pyplot and pylab to work on my Mac v.10.4.11
(Tiger). I've tried searching in both google and different macusers
forums, but haven't found an answer to my problems. If I have overlooked a
webpage please send me a link to the solution.

To download matplotlib I have downloaded the dmg package from the official
matplotlib page
http://sourceforge.net/projects/matplotlib/files/matplotlib/matplotlib-1.0/http://sourceforge.net/projects/matplotlib/files/matplotlib/matplotlib-1.0/

and it seems to install fine. However, I cannot use neither pyplot nor
pylab:

Hi,

I changed the script to what you suggested and this is the output:
[karianneholhjem:~] karianne% python bla.py --verbose-helpful
$HOME=/Users/karianne
CONFIGDIR=/Users/karianne/.matplotlib
matplotlib data path /Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/matplotlib/mpl-data
loaded rc file /Users/karianne/.matplotlib/matplotlibrc
matplotlib version 1.0.0
verbose.level helpful
interactive is False
units is False
platform is darwin
Bus error

I get the same output when commenting out either line 2 or 3.
(/Users/karianne/.matplotlib/matplotlibrc is just a link to
/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/matplotlib/mpl-data/matplotlibrc
as was in my previous output.)

Regarding numpy - what you say is intersting. I couldn't find any such
problems in my google-searches. I am running version 1.2.1:
[karianneholhjem:/] karianne% python -c 'import numpy; print numpy.__version__'
1.2.1

I couldn't find the version requirements in the README file so I probably
found the wrong README
(/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/numpy/README.txt).
It did provide a way of testing numpy, I don't know if it's interesting
but here is the output:

[karianneholhjem:/] karianne% python -c 'import numpy; numpy.test()'
Running unit tests for numpy
NumPy version 1.2.1
NumPy is installed in
/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/numpy
Python version 2.5.2 (r252:60911, Feb 22 2008, 07:57:53) [GCC 4.0.1 (Apple
Computer, Inc. build 5363)]
nose version 0.11.3
...........................................................................................................................................................................................................................................................................................................................................................................................................................................................K................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................

···

----------------------------------------------------------------------
Ran 1740 tests in 8.691s

OK (KNOWNFAIL=1)

Is there any more information I can provide to give you clues as of why
pyplot and pylab aren't working? Thank you for your help so far, I did a
course on python/numpy/matplotlib and I would really like to use
matplotlib as it is a really powerful plotting tool!

cheers,
Karianne

On Thu, 8 Jul 2010, John Hunter wrote:

On Thu, Jul 8, 2010 at 5:50 AM, Karianne Holhjem > <karianne@...1721...> wrote:
> Hi,
>
> I'm having trouble getting pyplot and pylab to work on my Mac v.10.4.11
> (Tiger). I've tried searching in both google and different macusers
> forums, but haven't found an answer to my problems. If I have overlooked a
> webpage please send me a link to the solution.
>
> To download matplotlib I have downloaded the dmg package from the official
> matplotlib page
> http://sourceforge.net/projects/matplotlib/files/matplotlib/matplotlib-1.0/http://sourceforge.net/projects/matplotlib/files/matplotlib/matplotlib-1.0/
>
> and it seems to install fine. However, I cannot use neither pyplot nor
> pylab:

You're on the right track with the debugging information you are
trying to provide. One problem is in your script bla.py. You do

  import matplotlib as mpl
  import mpl.pyplot
  import mpl.pylab

but you need to do

  import matplotlib as mpl
  import matplotlib.pyplot
  import matplotlib.pylab

This won't fix your segfault, but it may help you get get better
debugging information.

My first guess is a numpy version conflict -- what version are you
running? You can check the version requirements of the OSX installer
in the README that is provides. Many recent versions of numpy are not
ABI compatible, unfortunately.

JDH

Can you try upgrading numpy to the latest released version? This is
likely your problem. I would rm -rf the old numpy in your
site-packages directory and upgrade to 1.4.1

https://sourceforge.net/projects/numpy/files/NumPy/1.4.1/numpy-1.4.1-py2.5-python.org.dmg/download

Are you using python.org python or Apple python -- it appears the
installer above is for python.org python

JDH

···

On Fri, Jul 9, 2010 at 7:25 AM, Karianne Holhjem <karianne@...1721...> wrote:

Regarding numpy - what you say is intersting. I couldn't find any such
problems in my google-searches. I am running version 1.2.1:
[karianneholhjem:/] karianne% python -c 'import numpy; print numpy.__version__'
1.2.1

It works! Awsome! Thank you so much!!

I guess it is generally better to install everything that's using each
other's programs at the same time, or update what you already have to the
latest version upon installing more stuff.

Cheers,
Karianne

···

On Fri, 9 Jul 2010, John Hunter wrote:

On Fri, Jul 9, 2010 at 7:25 AM, Karianne Holhjem > <karianne@...1721...> wrote:

> Regarding numpy - what you say is intersting. I couldn't find any such
> problems in my google-searches. I am running version 1.2.1:
> [karianneholhjem:/] karianne% python -c 'import numpy; print numpy.__version__'
> 1.2.1

Can you try upgrading numpy to the latest released version? This is
likely your problem. I would rm -rf the old numpy in your
site-packages directory and upgrade to 1.4.1

https://sourceforge.net/projects/numpy/files/NumPy/1.4.1/numpy-1.4.1-py2.5-python.org.dmg/download

Are you using python.org python or Apple python -- it appears the
installer above is for python.org python

JDH