[Numpy-discussion] Use of numarray from numpy package [# INC NO 24609]

Sebastian Haase haase at msg.ucsf.edu
Thu Aug 31 00:11:05 CDT 2006


Andrew Straw wrote:
> LANDRIU David SAp wrote:
>> Hello,
>>   
>>   I come back to my question : how to use numarray 
>>  with the numpy installation ? 
>>   
>> {ccali22}~(0)>setenv PYTHONPATH /usr/local/lib/python2.3/site-packages/numpy
>>   
> Here's where you went wrong. You want:
> 
> setenv PYTHONPATH /usr/local/lib/python2.3/site-packages
> 
>> {ccali22}~(0)>python
>> Python 2.3.5 (#2, Oct 17 2005, 17:20:02)
>> [GCC 3.2.3 20030502 (Red Hat Linux 3.2.3-52)] on linux2
>> Type "help", "copyright", "credits" or "license" for more information.
>>   
>>>>> from numarray import *
>>>>>         
>> Traceback (most recent call last):
>>   File "<stdin>", line 1, in ?
>>   File "/usr/local/lib/python2.3/site-packages/numpy/numarray/__init__.py", line 1, in ?
>>     from util import *
>>   File "/usr/local/lib/python2.3/site-packages/numpy/numarray/util.py", line 2, in ?
>>     from numpy import geterr
>> ImportError: No module named numpy
>>   
> 
> Note that you're actually importing a numarray within numpy's directory
> structure. That's because of your PYTHONPATH. numpy ships numpy.numarray
> to provide backwards compatibility. To use it, you must do "import
> numpy.numarray as numarray"
> 

Just to explain -- there is only a numarray directory inside numpy
to provide some special treatment for people that do the transition from 
numarray to numpy  - meaning: they can do somthing like
from numpy import numarray
and get a "numpy(!) version"  that behaves more like numarray than the 
straight numpy ...

Similar for
"from numarray import oldnumaric as Numeric" (for people coming from 
Numeric )

Yes - it is actually confusing, but that's the baggage when there are 2 
(now 3) numerical python packages is human history.
The future will be much brighter  - forget all of the above, and just use
import numpy
(I like "import numpy as N" for less typing - others prefer even
"from numpy import *"
)

Hope that helps,
- Sebastian Haase





More information about the Numpy-discussion mailing list