[SciPy-User] scipy compiles, but importing interpolate fails

4 views
Skip to first unread message

Adam Ginsburg

unread,
Mar 8, 2012, 3:40:31 PM3/8/12
to scipy...@scipy.org
Hi, I've recently (surprisingly) gotten scipy to compile by following
these http://blog.hyperjeff.net/?p=160 instructions. However, if I
try to import scipy.interpolate, it fails. I'm trying to install
scipy into a virtualenv environment, though I don't think that's the
issue because I have another install in a Framework that sees the same
error.

I'm using numpy 1.6.1, scipy 0.10.1, mac OS X 10.6.8.

Can anyone help me understand the following error?

$ ~/virtual-python/bin/python -c "import scipy, scipy.interpolate"
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/Users/adam/virtual-python/lib/python2.7/site-packages/scipy/interpolate/__init__.py",
line 156, in <module>
from ndgriddata import *
File "/Users/adam/virtual-python/lib/python2.7/site-packages/scipy/interpolate/ndgriddata.py",
line 9, in <module>
from interpnd import LinearNDInterpolator, NDInterpolatorBase, \
File "numpy.pxd", line 174, in init interpnd
(scipy/interpolate/interpnd.c:7771)
ValueError: numpy.ndarray has the wrong size, try recompiling

Thanks,
--
Adam Ginsburg
Graduate Student
Center for Astrophysics and Space Astronomy
University of Colorado at Boulder
http://casa.colorado.edu/~ginsbura/
_______________________________________________
SciPy-User mailing list
SciPy...@scipy.org
http://mail.scipy.org/mailman/listinfo/scipy-user

Gael Varoquaux

unread,
Mar 8, 2012, 4:09:35 PM3/8/12
to SciPy Users List
On Thu, Mar 08, 2012 at 01:40:31PM -0700, Adam Ginsburg wrote:
> from interpnd import LinearNDInterpolator, NDInterpolatorBase, \
> File "numpy.pxd", line 174, in init interpnd
> (scipy/interpolate/interpnd.c:7771)
> ValueError: numpy.ndarray has the wrong size, try recompiling

My guess is that the numpy headers that were used during the compilation
of scipy do no correspond to the numpy that is being imported when you
are trying to import scipy. In other words, your compilation environment
doesn't match well your run time environment.

HTH,

Gael

Keflavich

unread,
Mar 8, 2012, 4:59:44 PM3/8/12
to scipy...@scipy.org
That's plausible. How do I specify which numpy is used when compiling
scipy?

On Mar 8, 2:09 pm, Gael Varoquaux <gael.varoqu...@normalesup.org>
wrote:

> SciPy-U...@scipy.orghttp://mail.scipy.org/mailman/listinfo/scipy-user

Gael Varoquaux

unread,
Mar 8, 2012, 5:01:40 PM3/8/12
to SciPy Users List
On Thu, Mar 08, 2012 at 01:59:44PM -0800, Keflavich wrote:
> That's plausible. How do I specify which numpy is used when compiling
> scipy?

It should be the one that is imported by Python when you type 'import
numpy'. Basically, in scipy's 'setup.py', the header are found using the
'numpy.get_include_folder()' function.

Gaël

Keflavich

unread,
Mar 8, 2012, 6:27:48 PM3/8/12
to scipy...@scipy.org
Well, it took another half-dozen clean rebuilds, but I got it
working. Thanks!

(clarification: it's numpy.get_include(), not
numpy.get_include_folder(), I think)

On Mar 8, 3:01 pm, Gael Varoquaux <gael.varoqu...@normalesup.org>
wrote:


> On Thu, Mar 08, 2012 at 01:59:44PM -0800, Keflavich wrote:
> > That's plausible.  How do I specify which numpy is used when compiling
> > scipy?
>
> It should be the one that is imported by Python when you type 'import
> numpy'. Basically, in scipy's 'setup.py', the header are found using the
> 'numpy.get_include_folder()' function.
>
> Gaël
> _______________________________________________
> SciPy-User mailing list

> SciPy-U...@scipy.orghttp://mail.scipy.org/mailman/listinfo/scipy-user

Gael Varoquaux

unread,
Mar 9, 2012, 1:31:20 AM3/9/12
to SciPy Users List
On Thu, Mar 08, 2012 at 03:27:48PM -0800, Keflavich wrote:
> Well, it took another half-dozen clean rebuilds, but I got it
> working. Thanks!

Well, good job on persisting: half a dozen rebuild is too much :). Do you
have an idea what finally made the difference?

> (clarification: it's numpy.get_include(), not
> numpy.get_include_folder(), I think)

Good point, I was writing this email in a rush, without checking my
facts.

Gael

> On Mar 8, 3:01 pm, Gael Varoquaux <gael.varoqu...@normalesup.org>
> wrote:
> > On Thu, Mar 08, 2012 at 01:59:44PM -0800, Keflavich wrote:
> > > That's plausible.  How do I specify which numpy is used when compiling
> > > scipy?

> > It should be the one that is imported by Python when you type 'import
> > numpy'. Basically, in scipy's 'setup.py', the header are found using the
> > 'numpy.get_include_folder()' function.

> > Gaël
> > _______________________________________________
> > SciPy-User mailing list
> > SciPy-U...@scipy.orghttp://mail.scipy.org/mailman/listinfo/scipy-user
> _______________________________________________
> SciPy-User mailing list
> SciPy...@scipy.org
> http://mail.scipy.org/mailman/listinfo/scipy-user

--
Gael Varoquaux
Researcher, INRIA Parietal
Laboratoire de Neuro-Imagerie Assistee par Ordinateur
NeuroSpin/CEA Saclay , Bat 145, 91191 Gif-sur-Yvette France
Phone: ++ 33-1-69-08-79-68
http://gael-varoquaux.info

Jonathan Guyer

unread,
Mar 9, 2012, 8:50:34 AM3/9/12
to SciPy Users List
My instructions to FiPy users are at: http://www.matforge.org/fipy/wiki/InstallFiPy/MacOSX/SnowLeopard

They're largely based on hyperjeff's, although his

sudo mv /System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python/numpy \
/System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python/numpyX

is evil and unnecessary if you pass --no-site-packages to mkvirtualenv.


I'm still on SciPy 0.9.0, but I don't have any trouble importing scipy.interpolate.

Keflavich

unread,
Mar 9, 2012, 11:46:24 AM3/9/12
to scipy...@scipy.org
re: Gael: I removed numpy and scipy completely from both my Frameworks
and virtualenv installs and removed the build directories from both.
However, I think that *still* didn't work. One part of the build that
probably caused problems was using this:
PYTHONPATH="/Library/Frameworks/Python.framework/Versions/2.7/lib/
python2.7/site-packages/"
which some site (maybe hyperjeff? maybe elsewhere?) said was
necessary for building scipy. I'm pretty sure getting rid of that in
the scipy build was essential.

My eventual successful build looked like this:
numpy:
CFLAGS="-arch i386 -arch x86_64" FFLAGS="-m32 -m64" LDFLAGS="-Wall -
undefined dynamic_lookup -bundle -arch i386 -arch x86_64"
MACOSX_DEPLOYMENT_TARGET=10.6 PYTHONPATH="/Library/Frameworks/
Python.framework/Versions/2.7/lib/python2.7/site-packages/" ~/virtual-
python/bin/python2.7 setup.py build --fcompiler=gnu95
scipy:
CFLAGS="-arch i386 -arch x86_64" FFLAGS="-m32 -m64" LDFLAGS="-Wall -
undefined dynamic_lookup -bundle -arch i386 -arch x86_64"
MACOSX_DEPLOYMENT_TARGET=10.6 PYTHONPATH="/Users/adam/virtual-python/
lib/python2.7/site-packages/" ~/virtual-python/bin/python2.7 setup.py
build --fcompiler=gnu95

Re: Jonathan - good to know. I don't think that affected me, though,
as I made my virtualenv from a /Library python, not a /System/Library
python. Why evil, though?

Gael Varoquaux

unread,
Mar 9, 2012, 11:57:36 AM3/9/12
to SciPy Users List
On Fri, Mar 09, 2012 at 08:46:24AM -0800, Keflavich wrote:
> re: Gael: I removed numpy and scipy completely from both my Frameworks
> and virtualenv installs and removed the build directories from both.
> However, I think that *still* didn't work. One part of the build that
> probably caused problems was using this:
> PYTHONPATH="/Library/Frameworks/Python.framework/Versions/2.7/lib/
> python2.7/site-packages/"
> which some site (maybe hyperjeff? maybe elsewhere?) said was
> necessary for building scipy. I'm pretty sure getting rid of that in
> the scipy build was essential.

Indeed, you story confirms my experience: a lot of build problem are
related to having several installs of Python, and having a hard time
controlling which one exactly is used when.

I don't know a good solution to these problems :(.

G

Jonathan Guyer

unread,
Mar 9, 2012, 12:55:41 PM3/9/12
to SciPy Users List

On Mar 9, 2012, at 11:46 AM, Keflavich wrote:

> Re: Jonathan - good to know. I don't think that affected me, though,
> as I made my virtualenv from a /Library python, not a /System/Library
> python. Why evil, though?

Because /System belongs to Apple and should not be tampered with. Using mkvirtualenv --no-site-packages means you don't have to. It doesn't matter how stale Apple's packages are; they get to have what they expect and you get to use what you want/need.

Reply all
Reply to author
Forward
0 new messages