Import Scipy problem

Post Reply
codonn

Import Scipy problem

Post by codonn »

Hi all

I have compiled neuron from source by hand-picking lines from the helpful script at
http://www.neuron.yale.edu/phpBB/viewto ... 1869#p6770

I am running OS X 10.6 with i386 arch.

I can then open NEURON successfully using

Code: Select all

nrniv -python
However I then have a problem importing scipy within NEURON. The response looks like:

Code: Select all

>>> import scipy
Traceback (most recent call last):
  File "stdin", line 1, in <module>
ImportError: No module named scipy
No such problem occurs with import numpy. What confuses me is that I have no problem importing scipy when in standard python.

Any tips?

On a separate note, I could not successfully install neuron as a python module using

Code: Select all

python setup.py install
from the neuron/nrn-7.1/src/nrnpython folder. It complained that it couldn't find a stdarg.h file.
I'm not sure if these two problems are related.
hines
Site Admin
Posts: 1600
Joined: Wed May 18, 2005 3:32 pm

Re: Import Scipy problem

Post by hines »

I wonder if the python you launched directly is the same as
the python that nrniv is using. ie. check in both cases with
import sys
sys.path

Also, I wonder if python, nrniv, and scipy are all using the same arch (i386 vs x86_64).
Is your machine really and i686 or is it an x86_64. If the latter then python may launch
as an i386 whereas when neuron launches, ti will start the x86_64 version and it may
be you only have an i386 version of the scipy libraries.
In that case, one possibility would be to build nrniv on your machine explicitly using
i386 arch.

The stdarg.h file problem is a puzzle without further details. If it was an x86_64 vs i386
problem I would have expecte a complaint about different architectures during linking.
stdarg.h is certainly a standard system include file. Can you find it on your hard drive?
codonn

Re: Import Scipy problem

Post by codonn »

Thanks for the speedy reply.
I wonder if the python you launched directly is the same as
the python that nrniv is using. ie. check in both cases with
import sys
sys.path
when I do that, the results look to me as though NEURON is pointing in the right place (i.e. same as direct launch python). But maybe you can see further than me:

Code: Select all

$ python
Python 2.6.6 (r266:84374, Aug 31 2010, 11:00:51) 
[GCC 4.0.1 (Apple Inc. build 5493)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.path
['', '/Users/codonn', '/Users/codonn/lib/python/site-packages', '/Library/Frameworks/Python.framework/Versions/2.6/lib/python26.zip', '/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6', '/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/plat-darwin', '/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/plat-mac', '/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/plat-mac/lib-scriptpackages', '/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/lib-tk', '/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/lib-old', '/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/lib-dynload', '/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages']
and

Code: Select all

$ nrniv -python
NEURON -- Release 7.1 (359:7f113b76a94b) 2009-10-26
Duke, Yale, and the BlueBrain Project -- Copyright 1984-2008
See http://www.neuron.yale.edu/credits.html

>>> import sys
>>> sys.path
['', '', '/Library/Python/2.6/site-packages/setuptools-0.6c11-py2.6.egg', '/Library/Python/2.6/site-packages/brian-1.3.0-py2.6.egg', '/Library/Python/2.6/site-packages/numpy-1.5.1-py2.6-macosx-10.6-universal.egg', '/Library/Python/2.6/site-packages/ipython-0.10.2-py2.6.egg', '/Library/Python/2.6/site-packages/nose-1.0.0-py2.6.egg', '/Users/codonn', '/Users/codonn/lib/python/site-packages', '/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python26.zip', '/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6', '/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/plat-darwin', '/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/plat-mac', '/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/plat-mac/lib-scriptpackages', '/System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python', '/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/lib-tk', '/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/lib-old', '/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/lib-dynload', '/Library/Python/2.6/site-packages', '/System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python/PyObjC', '/System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python/wx-2.8-mac-unicode', '/Applications/NEURON-7.1/nrn/share/nrn/lib/python']
As for
Also, I wonder if python, nrniv, and scipy are all using the same arch (i386 vs x86_64).
I checked my architecture:

Code: Select all

$ echo `uname -m`
i386
and when I installed NEURON I explicitly told it that it was i386 by adding

Code: Select all

CFLAGS='-arch i386' CXXFLAGS='-arch i386'
to the configure line. So pretty sure that is OK.
The stdarg.h file problem is a puzzle without further details. If it was an x86_64 vs i386
problem I would have expecte a complaint about different architectures during linking.
stdarg.h is certainly a standard system include file. Can you find it on your hard drive?
Yes, sorry I should have given more info. The stdarg.h file is exactly where the compiler looks for it, but the problem seems to happen on line 4 of the function when it refers to itself. Here is the error message:

Code: Select all

$ python setup.py install
running install
running build
running build_py
running build_ext
building 'neuron.hoc' extension
gcc -fno-strict-aliasing -fno-common -dynamic -isysroot /Developer/SDKs/MacOSX10.4u.sdk -arch ppc -arch i386 -g -O2 -DNDEBUG -g -O3 -I../.././src/oc -I../oc -I/Library/Frameworks/Python.framework/Versions/2.6/include/python2.6 -c inithoc.cpp -o build/temp.macosx-10.3-fat-2.6/inithoc.o
In file included from /Library/Frameworks/Python.framework/Versions/2.6/include/python2.6/unicodeobject.h:4,
                 from /Library/Frameworks/Python.framework/Versions/2.6/include/python2.6/Python.h:85,
                 from inithoc.cpp:8:
/Developer/SDKs/MacOSX10.4u.sdk/usr/include/stdarg.h:4:25: error: stdarg.h: No such file or directory
inithoc.cpp:30: warning: deprecated conversion from string constant to ‘char*’
inithoc.cpp:30: warning: deprecated conversion from string constant to ‘char*’
In file included from /Library/Frameworks/Python.framework/Versions/2.6/include/python2.6/unicodeobject.h:4,
                 from /Library/Frameworks/Python.framework/Versions/2.6/include/python2.6/Python.h:85,
                 from inithoc.cpp:8:
/Developer/SDKs/MacOSX10.4u.sdk/usr/include/stdarg.h:4:25: error: stdarg.h: No such file or directory
inithoc.cpp:30: warning: deprecated conversion from string constant to ‘char*’
inithoc.cpp:30: warning: deprecated conversion from string constant to ‘char*’
lipo: can't figure out the architecture type of: /var/folders/ae/aeQlCfzNHwqdjzdsPm1RSk+++TI/-Tmp-//ccZZcOK1.out
error: command 'gcc' failed with exit status 1
and here is the stdarg.h file from /Developer/SDKs/MacOSX10.4u.sdk/usr/include/stdarg.h :

Code: Select all

/* This file is public domain.  */
/* GCC uses its own copy of this header */
#if defined(__GNUC__)
#include_next <stdarg.h>
#elif defined(__MWERKS__)
#include "mw_stdarg.h"
#else
#error "This header only supports __MWERKS__."
#endif
hines
Site Admin
Posts: 1600
Joined: Wed May 18, 2005 3:32 pm

Re: Import Scipy problem

Post by hines »

The paths seem quite different in the sense that most of the /Library/Frameworks fo r the python launch
have a /System prefix in the nrniv launch. I have no idea if /System/Library is the same as /Library.
It would be interesting to see if scipy is only under /Library and if numpy is under both.
If so, you might try the experiment of explicitly adding some of the python path elements to the nrniv launch.


I guess I am troubled by the '-arch ppc' for setup.py since NEURON was only built for
'-arch i386'.
The stdarg.h that is being referred to is
#include_next <stdarg.h>
in your /Developer/SDKs/MacOSX10.4u.sdk/usr/include/stdarg.h
so apparently there is another version of stdarg.h that is supposed to
be included..
Post Reply