Cannot load compiled mod files from python

Anything that doesn't fit elsewhere.
Post Reply
Posts: 5
Joined: Tue Mar 03, 2020 11:33 am

Cannot load compiled mod files from python

Post by igor »


I started working with NEURON recently, mainly using Python. A friend of mine has written a library which, at one moment, compiles some mod files using

Code: Select all

which runs great building an x86_64/.libs/ directory with compiled library The compile procedure returns for each mod file compiled
"/Applications/NEURON-7.7/nrn/share/nrn/libtool" --tag=CC --mode=compile gcc -DHAVE_CONFIG_H -I. -I.. -I"/Applications/NEURON-7.7/nrn/include/nrn" -I"/Applications/NEURON-7.7/nrn/x86_64/lib" -g -O2 -c -o vecevent.lo vecevent.c
libtool: compile: gcc -DHAVE_CONFIG_H -I. -I.. -I/Applications/NEURON-7.7/nrn/include/nrn -I/Applications/NEURON-7.7/nrn/x86_64/lib -g -O2 -c vecevent.c -fno-common -DPIC -o .libs/vecevent.o
"/Applications/NEURON-7.7/nrn/share/nrn/libtool" --tag=CC --mode=link gcc -module -g -O2 -headerpad_max_install_names -o -rpath "/Applications/NEURON-7.7/nrn/x86_64/lib" CaDynamics_E2.lo Ca_HVA.lo Ca_LVAst.lo Ih.lo Im.lo K_Pst.lo K_Tst.lo NaTa_t.lo NaTs2_t.lo Nap_Et2.lo SK_E2.lo SKv3_1.lo syn_4p.lo vecevent.lo mod_func.lo -L"/Applications/NEURON-7.7/nrn/x86_64/lib" -lnrnoc -loc -lmemacs -lscopmath -lsparse13 -lreadline -lncurses -L"/Applications/NEURON-7.7/nrn/x86_64/lib" -lnrniv -livoc -lneuron_gnu -lmeschach -lsundials
libtool: link: gcc -Wl,-undefined -Wl,dynamic_lookup -o .libs/ -bundle .libs/CaDynamics_E2.o .libs/Ca_HVA.o .libs/Ca_LVAst.o .libs/Ih.o .libs/Im.o .libs/K_Pst.o .libs/K_Tst.o .libs/NaTa_t.o .libs/NaTs2_t.o .libs/Nap_Et2.o .libs/SK_E2.o .libs/SKv3_1.o .libs/syn_4p.o .libs/vecevent.o .libs/mod_func.o -L/Applications/NEURON-7.7/nrn/x86_64/lib /Applications/NEURON-7.7/nrn/x86_64/lib/libnrnoc.dylib /Applications/NEURON-7.7/nrn/x86_64/lib/liboc.dylib -L/usr/X11/lib -lX11 /Applications/NEURON-7.7/nrn/x86_64/lib/libmemacs.dylib /Applications/NEURON-7.7/nrn/x86_64/lib/libscopmath.dylib /Applications/NEURON-7.7/nrn/x86_64/lib/libsparse13.dylib /Applications/NEURON-7.7/nrn/x86_64/lib/libreadline.dylib -lncurses /Applications/NEURON-7.7/nrn/x86_64/lib/libnrniv.dylib /Applications/NEURON-7.7/nrn/x86_64/lib/libivoc.dylib /Applications/NEURON-7.7/nrn/x86_64/lib/libneuron_gnu.dylib /Applications/NEURON-7.7/nrn/x86_64/lib/libmeschach.dylib /Applications/NEURON-7.7/nrn/x86_64/lib/libsundials.dylib -g -O2
libtool: link: (cd ".libs" && rm -f "" && ln -s "" "")
libtool: link: ( cd ".libs" && rm -f "" && ln -s "../" "" )
Successfully created x86_64/special
At the end.

It is correct, since running nrniv from terminal runs successfully:

Code: Select all

(pytorch) MacBook-Pro-4:mods0 igor$ nrniv
NEURON -- VERSION 7.7.2 7.7 (2b7985ba) 2019-06-20
Duke, Yale, and the BlueBrain Project -- Copyright 1984-2018

loading membrane mechanisms from x86_64/.libs/
Additional mechanisms from files
 CaDynamics_E2.mod Ca_HVA.mod Ca_LVAst.mod Ih.mod Im.mod K_Pst.mod K_Tst.mod NaTa_t.mod NaTs2_t.mod Nap_Et2.mod SK_E2.mod SKv3_1.mod syn_4p.mod vecevent.mod
with all mechanisms being added.

On the other hand when trying to load it from Python

Code: Select all

import neuron
# ... neuron is initiated together with HocInterpreter object and then
(where h is the HocObject initialised object) fails with error output
dlopen failed -
dlopen(/Users/igor/git/neuronpp/neuronpp/examples/compiled/mods0/x86_64/.libs/, 2): Symbol not found: __ZN11ivMonoGlyph4bodyEP7ivGlyph
Referenced from: /Applications/NEURON-7.7/nrn/x86_64/lib/libnrniv.0.dylib
Expected in: flat namespace
in /Applications/NEURON-7.7/nrn/x86_64/lib/libnrniv.0.dylib
I tried whatever I could find in other answers on this forum.

I am using NEURON, on Mac OSX 10.15 Catalina and a Conda python 3.7.

What may be wrong?
Site Admin
Posts: 1619
Joined: Wed May 18, 2005 3:32 pm

Re: Cannot load compiled mod files from python

Post by hines »

The symbol that is not found would be in the interviews library and it is not clear to me why that is needed to successfully load the
file. Can you try the following test which loads the mod files for the neurondemo

Code: Select all

from neuron import h
But first verify that the path to the above is correct on your machine. From this we will know if the issue is general on your machine
or has something specific to do with your mod files. On my mac I am not experiencing the problem with the for the neurondemo, but I am also using a cmake build of the latest repository code. The relevant difference with the cmake build is that all the interviews names are actually inside the main libnrniv.dylib
Also, did you build from sources or use the pkg installer for NEURON?
Post Reply