Loading User-Defined Mechanisms

When Python is the interpreter, what is a good
design for the interface to the basic NEURON
concepts.

Moderator: hines

Post Reply
adamimos
Posts: 45
Joined: Mon Jan 25, 2010 4:49 pm

Loading User-Defined Mechanisms

Post by adamimos » Wed Feb 17, 2010 8:45 pm

Hello,

Sorry for all the questions; I am trying to just simply load up a .mod file via python. I have tried both the neuron.load_mechanisms and neuron.h.nrn_load_dll functions to no avail. In both cases I get this error:

Code: Select all


In [11]: h.nrn_load_dll('/Users/adamimos/Directory/umac/.libs/libnrnmech.so')
loading membrane mechanisms from /Users/adamimos/Directory/umac/.libs/libnrnmech.so
dlopen failed - 
dlopen(/Users/adamimos/Directory/umac/.libs/libnrnmech.so, 2): no suitable image found.  Did find:
	/Users/adamimos/Directory/umac/.libs/libnrnmech.so: no matching architecture in universal wrapper
Out[11]: 0.0
Any ideas? When using either hoc or the GUI it works fine...

Thanks,
Adam

hines
Site Admin
Posts: 1580
Joined: Wed May 18, 2005 3:32 pm

Re: Loading User-Defined Mechanisms

Post by hines » Thu Feb 18, 2010 7:40 am

I was successful on OSX 10.4 on an i686 with
nrniv -python
from neuron import h
h.nrn_load_dll('/Applications/NEURON-7.2/nrn/share/nrn/demo/release/umac/.libs/libnrnmech.so')

You can try the distributed shared library above but what other aspects are different in your case
(os, machine type, launch nrniv or python?)

adamimos
Posts: 45
Joined: Mon Jan 25, 2010 4:49 pm

Re: Loading User-Defined Mechanisms

Post by adamimos » Thu Feb 18, 2010 2:13 pm

I'm using OS X.6.2, i386, I was using python. I just tried nrrniv, and that works successfully...

hines
Site Admin
Posts: 1580
Joined: Wed May 18, 2005 3:32 pm

Re: Loading User-Defined Mechanisms

Post by hines » Thu Feb 18, 2010 4:43 pm

How did you install NEURON? With the distributed dmg or from the sources.
And if from the sources, how did you configure it. And if from the dmg how did
you get a launched python to know where the libraries and hoc files were so that
from neuron import h
would work.

adamimos
Posts: 45
Joined: Mon Jan 25, 2010 4:49 pm

Re: Loading User-Defined Mechanisms

Post by adamimos » Thu Feb 18, 2010 5:38 pm

I used this sequence of commands to install from source:

Code: Select all

#!/bin/sh                                                                                                  
#Install Neuron with InterViews and nrnpython interphase                                                   
                                                                                   
cd $HOME
mkdir neuron
cd neuron
                                        
cd iv
make distclean
sh build.sh
./configure --prefix=/Applications/nrn71_x86_64/iv \
    --build=x86_64-apple-darwin10 --host=x86_64-apple-darwin10 \
    CFLAGS='-O3 -arch x86_64 -m64 -fPIC -mfpmath=sse -msse3' CXXFLAGS='-O3 -arch x86_64 -m64 -fPIC -mfpmath=sse -msse3'

                                                                

make
make install
  
cd /Applications/nrn71_x86_64/iv

ln -s x86_64/lib lib                                                                                        

cd $HOME/nrn64/nrn
make distclean
sh build.sh
./configure --prefix=/Applications/nrn71_x86_64/nrn --with-iv=/Applications/nrn71_x86_64/iv \
    --with-x --x-includes=/usr/X11/include/ --x-libraries=/usr/X11/lib/ \
    --with-nrnpython=/opt/local/Library/Frameworks/Python.framework/Versions/2.6/Resources/Python.app/Contents/MacOS/Python \
    --host=x86_64-apple-darwin10 --build=x86_64-apple-darwin10 \
    --with-paranrn \
    CFLAGS='-O3 -arch x86_64 -m64 -fPIC -mfpmath=sse -msse3' CXXFLAGS='-O3 -arch x86_64 -m64 -fPIC -mfpmath=sse -msse3' \
    PYLIB=-lpython PYLIBLINK=-lpython

                                                 

make
make install
make after_install

#You should now have a working NEURON application under Applications. Small test;                          
sudo /Applications/nrn71_x86_64/nrn/x86_64/bin/neurondemo                                                                 


#If this works, you should add /Applications/nrn7.1/nrn/x86_64/bin/ to your PATH variable.                   

#Final step is to install neuron as a python module                                                        
cd src/nrnpython
sudo /opt/local/bin/python setup.py install


hines
Site Admin
Posts: 1580
Joined: Wed May 18, 2005 3:32 pm

Re: Loading User-Defined Mechanisms

Post by hines » Thu Feb 18, 2010 6:43 pm

I'm a little confused because earlier you said you were using an i386 architecture but the build is
for an x86_64 architecture.
So when launching python, the question is now which architecture it uses. I'm guessing it works the
other way around (launch nrniv) because the python library is universal and so the right arch loads
dynamically. But in your build you only have the x86_64.

Post Reply