Page 1 of 1

building py-neuron module on 10.6 problem

Posted: Sat Oct 24, 2009 3:26 pm
by selfdestructo
Hi!

I'm trying to produce the neuron module for my native Python 2.6.3 installation on a macbook pro 15 with OS X 10.6 (Snow Leopard). I've installed XCode 3.2.1 (full install).

I am working with the hg repositories of IV and NEURON. --enable-carbon with configure will not work for neither of these, so I have compiled NEURON using

Code: Select all

sh build.sh
./configure ./configure --prefix=/Applications/NEURON-7.1/nrn --without-iv --with-nrnpython --enable-UniversalMacBinary PYLIBLINK='-framework Python' PYLIB='-framework Python'
make
make install
cd /src/nrnpython/

iv will compile using ./configure --prefix=/Applications/NEURON-7.1/iv/ --enable-UniversalMacBinary, but it will not work with the NEURON configure thing using --with-iv=/Applications/NEURON-7.1/iv/. Iv is not necessary for the neuron python module, no?

Then I edit setup.py; changing the nrnpython_exec-line to
nrnpython_exec = "/Library/Frameworks/Python.framework/Versions/2.6/Resources/Python.app/Contents/MacOS/Python"

running python setup.py install yield the following error message

Code: Select all

imt-iw23013124:nrnpython aehagen$ python setup.py install
running install
running build
running build_py
running build_ext
building 'neuron.hoc' extension
g++ -arch ppc -arch i386 -isysroot /Developer/SDKs/MacOSX10.4u.sdk -g -bundle -undefined dynamic_lookup build/temp.macosx-10.3-fat-2.6/inithoc.o -L/Applications/NEURON-7.1/nrn/umac/lib -L -lnrnpython -lnrnoc -loc -lnrniv -livoc -lmemacs -lmeschach -lneuron_gnu -lnrnmpi -lscopmath -lsparse13 -lsundials -lIVhines -lreadline -o build/lib.macosx-10.3-fat-2.6/neuron/hoc.so
ld: library not found for -lIVhines
collect2: ld returned 1 exit status
ld: library not found for -lIVhines
collect2: ld returned 1 exit status
lipo: can't open input file: /var/folders/HY/HYDLuOTlFy4uSRaI4jMNdk+++TQ/-Tmp-//cczBEN2L.out (No such file or directory)
error: command 'g++' failed with exit status 1
It looks to me that some IV stuff is still needed, I don't understand much of this. Seems to me that others can build this module successfully, why not me? What can I do different?

Re: building py-neuron module on 10.6 problem

Posted: Sun Oct 25, 2009 12:20 pm
by hines
If you have an x86_64 machine then --enable-carbon is not supported at present.
For simplicity do not use the --enable-UniversalMacBinary (you do not need to run on a powerpc)
Iv is not necessary for the neuron python module
InterViews is not necessary. But it should work if compiled without the --enable-carbon option
(i.e. as an x11 program)

I never ran setup.py when neuron was '--without-iv' and forgot to allow setup.py handle that case.
If you don't want iv, then edit setup.py and delete the "IVhines" word.

Re: building py-neuron module on 10.6 problem

Posted: Sun Oct 25, 2009 3:48 pm
by selfdestructo
Thanks, removing the lIVhines thing did it, a neuron module is found by Python. It will not load properly though;

Code: Select all

In [1]: import neuron
/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/neuron/__init__.py:92: DeprecationWarning: BaseException.message has been deprecated as of Python 2.6
  """%e.message
---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)

/Users/aehagen/neuron/nrn/src/nrnpython/<ipython console> in <module>()

/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/neuron/__init__.py in <module>()
     90 %s
     91 
---> 92 """%e.message
     93 
     94 

ImportError: 
Can't import neuron.hoc module.

In case you are importing neuron from within
a directory containing neuron/__init__.py
which is not the installed neuron package for python,
move out of this directory and try again.

The original error message was: 

dlopen(/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/neuron/hoc.so, 2): Symbol not found: __ZN10ivObserver6updateEP12ivObservable
  Referenced from: /Applications/NEURON-7.1/nrn/umac/lib/libnrniv.0.dylib
  Expected in: flat namespace
 in /Applications/NEURON-7.1/nrn/umac/lib/libnrniv.0.dylib
I've tried to locate the neuron.hoc file, but I can't find it anywhere.

Compiling iv so the neuron configure can find it will not work whatever what I do, it seems. Will look more into it tomorrow.

Re: building py-neuron module on 10.6 problem

Posted: Mon Oct 26, 2009 9:41 am
by selfdestructo
Well, it turns out that I can compile Neuron with --with-iv by pointing it to the iv-folder included in the precompiled NEURON 7.0 package for OS X 10.4. For it to work, I had to copy the lib folder contained within umac, up in the iv-folder. It was not found otherwise. I tried the same with iv compiled by myself, but it did not work.

My problem regarding the neuron.hoc-module described above persist though.

Thanks,
Espen.

Re: building py-neuron module on 10.6 problem

Posted: Tue Oct 27, 2009 5:54 pm
by selfdestructo
I finally had some success. I ended up using the as of today current source tar-balls. For future reference I think I used the following procedure;

Code: Select all

#building iv;
tar xzf iv-17.tar.gz
cd iv-17
sh build.sh
./configure --prefix=/Applications/NEURON-7.1/iv --enable-UniversalMacBinary
make
make install

#linking up iv so the nrn-configure can find it where it expect it, would fail otherwise
cd /usr/local/
sudo ln -s /Applications/NEURON-7.1/iv iv

#cd /wherever nrn-7.1.tar.gz is
tar xzf nrn-7.1.tar.gz
cd nrn-7.1
sh build.sh
./configure --prefix=/Applications/NEURON-7.1/nrn --with-iv=/Applications/iv/ --with-nrnpython --enable-UniversalMacBinary PYLIB='-lpython' PYLIBLINK='-lpython'

#at this point, the applications under the installdir/nrn/umac/bin seem to work, ie. nrniv, neurondemo etc seem to work

#compiling the python module;
cd src/nrnpython/
emacs setup.py #edit: nrnpython_exec = "/Library/Frameworks/Python.framework/Versions/2.6/Resources/Python.app/Contents/MacOS/Python"
python setup.py install

#the following now work
python
>>>import neuron
Have not had time to test out much, but the supplied test scripts appear to work.

Re: building py-neuron module on 10.6 problem

Posted: Thu Oct 29, 2009 7:31 am
by hines

Code: Select all

sudo ln -s /Applications/NEURON-7.1/iv iv
No need to link. If iv is not installed in one of the well-known places then you can use
the configure arg
--with-iv=/where/iv/is/installed

The well-known places are:
<prefix>/../iv
/usr/local/iv
anywhere that -lIVhines succeeds during linking without an explicit -L...

Re: building py-neuron module on 10.6 problem

Posted: Thu Dec 31, 2009 11:10 am
by GraeGreene
Hello,

I'm having a somewhat similar problem building the python neuron module. Both IV and NEURON appear to compile and install correctly, but when I try to run setup.py (using python setup.py install), I get a long string of errors, some of which I'll quote below.

Code: Select all

$ python setup.py install
running install
running build
running build_py
creating build
creating build/lib.macosx-10.3-fat-2.6
creating build/lib.macosx-10.3-fat-2.6/neuron
copying ../.././share/lib/python/neuron/__init__.py -> build/lib.macosx-10.3-fat-2.6/neuron
copying ../.././share/lib/python/neuron/doc.py -> build/lib.macosx-10.3-fat-2.6/neuron
copying ../.././share/lib/python/neuron/gui.py -> build/lib.macosx-10.3-fat-2.6/neuron
copying ../.././share/lib/python/neuron/sections.py -> build/lib.macosx-10.3-fat-2.6/neuron
creating build/lib.macosx-10.3-fat-2.6/neuron/tests
copying ../.././share/lib/python/neuron/tests/__init__.py -> build/lib.macosx-10.3-fat-2.6/neuron/tests
copying ../.././share/lib/python/neuron/tests/test_all.py -> build/lib.macosx-10.3-fat-2.6/neuron/tests
copying ../.././share/lib/python/neuron/tests/test_vector.py -> build/lib.macosx-10.3-fat-2.6/neuron/tests
running build_ext
building 'neuron.hoc' extension
creating build/temp.macosx-10.3-fat-2.6
Compiling with an SDK that doesn't seem to exist: /Developer/SDKs/MacOSX10.4u.sdk
Please check your Xcode installation
mpicc -arch ppc -arch i386 -isysroot /Developer/SDKs/MacOSX10.4u.sdk -fno-strict-aliasing -fno-common -dynamic -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
inithoc.cpp:3:17: error: mpi.h: No such file or directory
inithoc.cpp:5:19: error: stdio.h: No such file or directory
In file included from inithoc.cpp:8:
/Library/Frameworks/Python.framework/Versions/2.6/include/python2.6/Python.h:19:20: error: limits.h: No such file or directory
/Library/Frameworks/Python.framework/Versions/2.6/include/python2.6/Python.h:22:2: error: #error "Something's broken.  UCHAR_MAX should be defined in limits.h."
/Library/Frameworks/Python.framework/Versions/2.6/include/python2.6/Python.h:26:2: error: #error "Python's source code assumes C's unsigned char is an 8-bit type."
/Library/Frameworks/Python.framework/Versions/2.6/include/python2.6/Python.h:35:5: error: #error "Python.h requires that stdio.h define NULL."
/Library/Frameworks/Python.framework/Versions/2.6/include/python2.6/Python.h:38:20: error: string.h: No such file or directory
Following this, there are many errors for variable not naming types and such. I don't really understand this stuff that well, so any insights would be appreciated. Things seem to be fine until this: "Compiling with an SDK that doesn't seem to exist: /Developer/SDKs/MacOSX10.4u.sdk". I don't know how to tell it to use MacOSX10.6.sdk. My Xcode installation is the latest version 3.2.1 downloaded from Apple (which I tried after the installation from the DVD didn't work). I've tried all the suggestions in the various forum posts and I can't get any of them to work.

Many thanks,
Matt

*Edit*: Just thought I should add the final error produced before it gives up:

Code: Select all

error: command 'mpicc' failed with exit status 1

Re: building py-neuron module on 10.6 problem

Posted: Thu Dec 31, 2009 11:45 am
by hines
My faintly possible guess is that the python used to setup is different from the python used in the building of NEURON.
Or possibly the mpi, NEURON, python, xcode packages are inconsistent with osx 10.6 or each other.
Both IV and NEURON appear to compile and install correctly
Does it also work with python, ie. can you launch from a terminal window
nrniv -python
from neuron import h

What version of the NEURON sources are you using and how did you configure?
mpicc -arch ppc -arch i386
The -arch i386 is important if your machine is an x86_64 but I'd avoid the configure option of
--enable-UniversaMacBinary and get it explicitly with CFLAGS='-arch i386' CXXFLAGS='-arch i386'
Also I'd build without the --with-paranrn or --with-nrnmpi options to see if the problem is related to
your mpi installation.

Re: building py-neuron module on 10.6 problem

Posted: Thu Dec 31, 2009 12:46 pm
by GraeGreene
Hi and thanks for the quick reply!

I did have both Python 2.6 and 3.1 installed, so I've removed 3.1 to make sure the same version is used throughout.

I'm using the current standard distribution (v7.1), which I downloaded from http://www.neuron.yale.edu/neuron/download/getstd
Does it also work with python, ie. can you launch from a terminal window
nrniv -python
from neuron import h
No, that doesn't seem to work either.

I configured and installed interviews like so:

Code: Select all

sh build.sh
./configure --prefix=/Applications/NEURON-7.1/iv
make 
make install
And for NEURON:

Code: Select all

sh build.sh
./configure --prefix=/Applications/NEURON-7.1/nrn --build=i386 --with-iv=/Applications/NEURON-7.1/iv --with-nrnpython CFLAGS="-arch i386" CXXFLAGS="-arch i386"
make 
make install
I got the configure line from this post: http://www.neuron.yale.edu/phpBB/viewto ... f=4&t=1769

I've just tried all of this again and now, when configuring NEURON, it doesn't find iv. As far as I can tell, there were no problems with the iv install and it is definitely in the directory indicated in '--with-iv='. What am I doing wrong?

Re: building py-neuron module on 10.6 problem

Posted: Thu Dec 31, 2009 1:16 pm
by hines
let's move this to email <michael dot hines at yale dot edu> and I'll sumarize later if there is
something substantive involved. Since you are not using --enable-carbon, there is no reason
to set the -arch because you are building against x11 and there should be no problem with x11
even if your machine is an x86_64. (Is your machine an x86_64? Do you wish to use x11 or carbon?)
I also see that mpi is not being invoked. good.
No, that doesn't seem to work either.
So we need to get the basic installation going before proceeding further.
now, when configuring NEURON, it doesn't find iv
According to the InterViews configuration, you did not specify -arch and so the libraries are possibly installed in
/Applications/NEURON-7.1/iv/x86_64/lib
assuming your machine is an x86_64. At any rate, if you wish to use x11, then leave off the -arch for both InterViews and NEURON.
ie. for InterViews
./configure --prefix=/Applications/NEURON-7.1/iv
make
make install
and for NEURON
./configure --prefix=/Applications/NEURON-7.1/nrn --with-iv=/Applications/NEURON-7.1/iv --with-nrnpython
make
make install

and test in a terminal first with
/Applications/NEURON-7.1/nrn/x86_64/bin/neurondemo
and then with
/Applications/NEURON-7.1/nrn/86_64/bin/nrniv -python
import neuron

Re: building py-neuron module on 10.6 problem

Posted: Wed Jan 06, 2010 7:12 am
by hines
The original problem experienced by GraeGreen was not completely resolved but
I eventually got everything working by building python from source.