Problem about NEURON+Python, using hoc file

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

Moderator: hines

Post Reply
yax317

Problem about NEURON+Python, using hoc file

Post by yax317 » Mon Jul 24, 2017 9:39 am

Hi everyone,

I ran into a problem while using Python+NEURON, and it makes me confused a lot, could you please give me any suggestions?

I installed NEURON -- Release 7.4 (1370:16a7055d4a86) 2015-11-09 on Ubuntu 14.04, which is a virtual machine, and the version of my Python is
Python 2.7.6 (default, Oct 26 2016, 20:30:19) [GCC 4.8.4] on linux2.

I can use nrnivmodl+nrngui to launch my hoc file successfully, but I can not launch the python file using a hoc file, which applys a mod file.

When I use nrnivmodl to compile my .mod file, it shows:
Creating x86_64 directory for .o files.

/home/xiaoyao/code
stdwa_songabbott.mod
stdwa_songabbott.mod
"/usr/local/nrn/x86_64/bin/nocmodl" stdwa_songabbott
Translating stdwa_songabbott.mod into stdwa_songabbott.c
Notice: Use of POINTER is not thread safe.
"/usr/local/nrn/share/nrn/libtool" --tag=CC --mode=compile gcc -DHAVE_CONFIG_H -I. -I.. -I"/usr/local/nrn/include/nrn" -I"/usr/local/nrn/x86_64/lib" -g -O2 -c -o stdwa_songabbott.lo stdwa_songabbott.c
libtool: compile: gcc -DHAVE_CONFIG_H -I. -I.. -I/usr/local/nrn/include/nrn -I/usr/local/nrn/x86_64/lib -g -O2 -c stdwa_songabbott.c -fPIC -DPIC -o .libs/stdwa_songabbott.o
"/usr/local/nrn/share/nrn/libtool" --tag=CC --mode=compile gcc -DHAVE_CONFIG_H -I. -I.. -I"/usr/local/nrn/include/nrn" -I"/usr/local/nrn/x86_64/lib" -g -O2 -c -o mod_func.lo mod_func.c
libtool: compile: gcc -DHAVE_CONFIG_H -I. -I.. -I/usr/local/nrn/include/nrn -I/usr/local/nrn/x86_64/lib -g -O2 -c mod_func.c -fPIC -DPIC -o .libs/mod_func.o
"/usr/local/nrn/share/nrn/libtool" --tag=CC --mode=link gcc -module -g -O2 -o libnrnmech.la -rpath "/usr/local/nrn/x86_64/lib" stdwa_songabbott.lo mod_func.lo -L"/usr/local/nrn/x86_64/lib" -lnrnoc -loc -lmemacs -lscopmath -lsparse13 -lreadline -lncurses -L"/usr/local/nrn/x86_64/lib" "/usr/local/nrn/x86_64/lib/libnrniv.la" -livoc -lneuron_gnu -lmeschach -lsundials -lm -ldl
libtool: link: gcc -shared -fPIC -DPIC .libs/stdwa_songabbott.o .libs/mod_func.o -Wl,-rpath -Wl,/usr/local/nrn/x86_64/lib -Wl,-rpath -Wl,/usr/local/nrn/x86_64/lib -L/usr/local/nrn/x86_64/lib /usr/local/nrn/x86_64/lib/libnrnoc.so /usr/local/nrn/x86_64/lib/liboc.so /usr/local/nrn/x86_64/lib/libmemacs.so /usr/local/nrn/x86_64/lib/libscopmath.so /usr/local/nrn/x86_64/lib/libsparse13.so /usr/local/nrn/x86_64/lib/libreadline.so -lncurses /usr/local/nrn/x86_64/lib/libnrniv.so /usr/local/nrn/x86_64/lib/libivoc.so /usr/local/nrn/x86_64/lib/libneuron_gnu.so /usr/local/nrn/x86_64/lib/libmeschach.so /usr/local/nrn/x86_64/lib/libsundials.so -lm -ldl -O2 -pthread -Wl,-soname -Wl,libnrnmech.so.0 -o .libs/libnrnmech.so.0.0.0
libtool: link: (cd ".libs" && rm -f "libnrnmech.so.0" && ln -s "libnrnmech.so.0.0.0" "libnrnmech.so.0")
libtool: link: (cd ".libs" && rm -f "libnrnmech.so" && ln -s "libnrnmech.so.0.0.0" "libnrnmech.so")
libtool: link: ( cd ".libs" && rm -f "libnrnmech.la" && ln -s "../libnrnmech.la" "libnrnmech.la" )
Successfully created x86_64/special
and I can use nrngui to launch my .hoc file successfully.
xiaoyao@xiaoyao-VirtualBox:~/Yaocode$ nrngui stdp.hoc
NEURON -- Release 7.4 (1370:16a7055d4a86) 2015-11-09
Duke, Yale, and the BlueBrain Project -- Copyright 1984-2015
See http://www.neuron.yale.edu/neuron/credits

loading membrane mechanisms from /home/xiaoyao/Yaocode/x86_64/.libs/libnrnmech.so
Additional mechanisms from files
stdwa_songabbott.mod
1
oc>
This is the right result, isn't it?
But when I use hoc file in my Python code, it occurs an error, says:
xiaoyao@xiaoyao-VirtualBox:~/Yaocode$ python ntest.py
NEURON -- Release 7.4 (1370:16a7055d4a86) 2015-11-09
Duke, Yale, and the BlueBrain Project -- Copyright 1984-2015
See http://www.neuron.yale.edu/neuron/credits

loading membrane mechanisms from x86_64/.libs/libnrnmech.so
dlopen failed -
x86_64/.libs/libnrnmech.so: undefined symbol: nrnmpi_myid
1
NEURON: StdwaSA is not a template
in stdp.hoc near line 19
wa = new StdwaSA(1)
^
xopen("stdp.hoc")
execute1("{xopen("st...")
load_file("stdp.hoc")
0


What's more, if I apply a hoc file in my python code, where mod file is not used, there is no error.
It really confuses me. And I tried almost every way in the forum to fix the problem these days, but it just doesn't work.

Could you please help with this problem?
Thank you so much for your time.

ramcdougal
Posts: 141
Joined: Fri Nov 28, 2008 3:38 pm
Location: Yale School of Medicine

Re: Problem about NEURON+Python, using hoc file

Post by ramcdougal » Mon Jul 24, 2017 3:27 pm

Most immediately, the problem is that in Python libnrnmech.so is failing to load, and without that the mod file mechanisms -- in particular StdwaSA -- are unavailable. Had it loaded successfully, you wouldn't have gotten the error "dlopen failed"; instead, you would have seen the same "additional mechanisms from files" message as before.

On my computer, in a directory with stdwa_songabbott.mod, importing neuron from Python looks like:

Code: Select all

$ python
Python 2.7.6 (default, Jun 22 2015, 17:58:13)
[GCC 4.8.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from neuron import h
NEURON -- VERSION 7.5 master (51b7a8c) 2017-07-04
Duke, Yale, and the BlueBrain Project -- Copyright 1984-2016
See http://neuron.yale.edu/neuron/credits

loading membrane mechanisms from x86_64/.libs/libnrnmech.so
Additional mechanisms from files
 stdwa_songabbott.mod
>>>
Now as far as why this is happening...

Is it possible that there are two versions of NEURON on your machine, one compiled with MPI support (the one that nrnivmodl and nrngui are using) and one without (the one that Python is using)?

yax317

Re: Problem about NEURON+Python, using hoc file

Post by yax317 » Tue Jul 25, 2017 1:34 pm

ramcdougal wrote:Most immediately, the problem is that in Python libnrnmech.so is failing to load, and without that the mod file mechanisms -- in particular StdwaSA -- are unavailable. Had it loaded successfully, you wouldn't have gotten the error "dlopen failed"; instead, you would have seen the same "additional mechanisms from files" message as before.

On my computer, in a directory with stdwa_songabbott.mod, importing neuron from Python looks like:

Code: Select all

$ python
Python 2.7.6 (default, Jun 22 2015, 17:58:13)
[GCC 4.8.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from neuron import h
NEURON -- VERSION 7.5 master (51b7a8c) 2017-07-04
Duke, Yale, and the BlueBrain Project -- Copyright 1984-2016
See http://neuron.yale.edu/neuron/credits

loading membrane mechanisms from x86_64/.libs/libnrnmech.so
Additional mechanisms from files
 stdwa_songabbott.mod
>>>
Now as far as why this is happening...

Is it possible that there are two versions of NEURON on your machine, one compiled with MPI support (the one that nrnivmodl and nrngui are using) and one without (the one that Python is using)?
Thank you for your kind reply!
I have removed python3 from my computer and it works!
Thank you a lot!

Post Reply