John Harrold | 7 Oct 21:22

ImportError: No module named ma

Howdy,

I'm trying to run some scripts associated with a paper I was reading. They use
the matplotlib to generate figures which in turn calles numpy. I'm new to
python, but I'm very familiar with perl. I'm getting the following error, and
I'm not quite sure what is causing it. Can anyone here offer any suggestions?

jmh <at> dhcp068-156:$ python2.5  Bb-plot.py 
Traceback (most recent call last):
  File "Bb-plot.py", line 7, in <module>
    from pylab import *
  File "/Library/Python/2.5/site-packages/matplotlib-0.98.3-py2.5.egg/pylab.py", line 1, in <module>
    from matplotlib.pylab import *
  File
"/Library/Python/2.5/site-packages/matplotlib-0.98.3-py2.5.egg/matplotlib/__init__.py",
line 128, in <module>
    from rcsetup import defaultParams, validate_backend, validate_toolbar
  File "/Library/Python/2.5/site-packages/matplotlib-0.98.3-py2.5.egg/matplotlib/rcsetup.py",
line 19, in <module>
    from matplotlib.colors import is_color_like
  File "/Library/Python/2.5/site-packages/matplotlib-0.98.3-py2.5.egg/matplotlib/colors.py",
line 39, in <module>
    import matplotlib.cbook as cbook
  File "/Library/Python/2.5/site-packages/matplotlib-0.98.3-py2.5.egg/matplotlib/cbook.py",
line 9, in <module>
    import numpy.ma as ma
ImportError: No module named ma

--

-- 
 John M Harrold              
(Continue reading)

Pierre GM | 7 Oct 21:23

Re: ImportError: No module named ma

On Tuesday 07 October 2008 15:23:58 John Harrold wrote:

> "/Library/Python/2.5/site-packages/matplotlib-0.98.3-py2.5.egg/matplotlib/c
>book.py", line 9, in <module> import numpy.ma as ma
> ImportError: No module named ma

John,
Are you sure you have numpy installed ? What version do you have ?
| 7 Oct 21:32
Favicon

Re: ImportError: No module named ma

Hi John

2008/10/7 John Harrold <john.m.harrold <at> gmail.com>:
> I'm trying to run some scripts associated with a paper I was reading. They use
> the matplotlib to generate figures which in turn calles numpy. I'm new to
> python, but I'm very familiar with perl. I'm getting the following error, and
> I'm not quite sure what is causing it. Can anyone here offer any suggestions?
>
> jmh <at> dhcp068-156:$ python2.5  Bb-plot.py
> Traceback (most recent call last):
>  File "Bb-plot.py", line 7, in <module>
>    from pylab import *
>  File "/Library/Python/2.5/site-packages/matplotlib-0.98.3-py2.5.egg/pylab.py", line 1, in <module>
>    from matplotlib.pylab import *
>  File
"/Library/Python/2.5/site-packages/matplotlib-0.98.3-py2.5.egg/matplotlib/__init__.py",
line 128, in <module>
>    from rcsetup import defaultParams, validate_backend, validate_toolbar
>  File
"/Library/Python/2.5/site-packages/matplotlib-0.98.3-py2.5.egg/matplotlib/rcsetup.py",
line 19, in <module>
>    from matplotlib.colors import is_color_like
>  File "/Library/Python/2.5/site-packages/matplotlib-0.98.3-py2.5.egg/matplotlib/colors.py",
line 39, in <module>
>    import matplotlib.cbook as cbook
>  File "/Library/Python/2.5/site-packages/matplotlib-0.98.3-py2.5.egg/matplotlib/cbook.py",
line 9, in <module>
>    import numpy.ma as ma
> ImportError: No module named ma

(Continue reading)

John Harrold | 7 Oct 21:40

Re: ImportError: No module named ma

Sometime in October, St?fan van der Walt proposed the following: 

| Could you give us the version of NumPy that you are using?
| 
| >>> import numpy
| >>> print numpy.__version__
| 
| As far as I recall, the masked array module was always available as
| numpy.ma, but maybe I'm wrong.  Could you try the following:
| 
| >>> import numpy
| >>> print numpy.core.ma
| 

Howdy Stefan and Pierre

This should answer both of your questions:

>>> import numpy
>>> print numpy.__version__
1.0.1
>>> print numpy.core.ma
<module 'numpy.core.ma' from
'/System/Library/Frameworks/Python.framework/Versions/2.5/Extras/lib/python/numpy/core/ma.pyc'>
>>> 

I actually installed 1.2.0 using the installation package for OS X.
However, I have no idea where it was installed to and how to instruct
python to use the new one over the old.

(Continue reading)

Christopher Barker | 7 Oct 21:47
Favicon

Re: ImportError: No module named ma

John Harrold wrote:
> This should answer both of your questions:
> 
>>>> import numpy
>>>> print numpy.__version__
> 1.0.1
>>>> print numpy.core.ma
> <module 'numpy.core.ma' from
> '/System/Library/Frameworks/Python.framework/Versions/2.5/Extras/lib/python/numpy/core/ma.pyc'>
> 
> I actually installed 1.2.0 using the installation package for OS X.
> However, I have no idea where it was installed to and how to instruct
> python to use the new one over the old.

the installation package for OS-X is for the python.org build -- from 
the above, I can see you are running Apple's python, which came with a 
version of numpy.

I don't remember how you installed matplotlib, but in general, most 
extrenal packages are built for the python or python, so what I wold do is:

download and install python 2.5.2 from python.org (2.6 is brand new, and 
not yet well supported by external packages)

re-install numpy 1.2.0 (may not be necessary, but it won't hurt)

re-install MPL.

you can tell what python you are running by typing "python" n the 
command line -- it should be 2.5.2 if it's the python.org one. If that's 
(Continue reading)

John Harrold | 8 Oct 00:18

Re: ImportError: No module named ma

Sometime in October, Christopher Barker proposed the following: 

| the installation package for OS-X is for the python.org build -- from 
| the above, I can see you are running Apple's python, which came with a 
| version of numpy.
| 
| I don't remember how you installed matplotlib, but in general, most 
| extrenal packages are built for the python or python, so what I wold do is:
| 
| download and install python 2.5.2 from python.org (2.6 is brand new, and 
| not yet well supported by external packages)
| 
| re-install numpy 1.2.0 (may not be necessary, but it won't hurt)
| 
| re-install MPL.
| 
| you can tell what python you are running by typing "python" n the 
| command line -- it should be 2.5.2 if it's the python.org one. If that's 
| not what you get, you may need to edit your .bash_profile file to add it 
| to your PATH.
| 

Thanks Chris,

This worked great. Along with the above mentioned stuff, I also  had a bit
of trouble installing the MPL egg which seems to be mac specific.  This was
also pretty useful in fixing that:

http://www.nabble.com/OS-X-(Intel-Mac)-installation-woes-td19011120.html

(Continue reading)


Gmane