[Win64][7.4][Canopy] "dlopen failed" and python crash

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

Moderator: hines

Post Reply
CYUlysses
Posts: 8
Joined: Mon Apr 06, 2015 12:54 pm

[Win64][7.4][Canopy] "dlopen failed" and python crash

Post by CYUlysses »

Dear Hines/Ted/other fellows, I am having an error trying to load a .hoc file by load_file via the Python interface.

I installed the latest 7.4 stable release for win64 system and installed the win64 version Enthought Canopy Python. After setting NEURONHOME and PYTHONPATH to the corresponding directories, I was able to import neuron if I started Python in the bash terminal, but could not import neuron if I started the Python process elsewhere; this problem was solved using the method mentioned by hines here:
viewtopic.php?f=5&t=2604&hilit=DLL+load+failed&start=15
(page 2, bottom)

However, when I tried loading hoc files with h.load_file("filename.hoc") or h('load_file("filename.hoc")'), the message
"dlopen failed -"
will pop up, and windows will say "python.exe has stopped working". It happened both in the bash-initiated python and directly initiated pythons, and does not matter whether the .hoc file procedure involves GUI components. For some files, the error message would say
"loadlibrary("nrnmech.dll") failed with error 126"
, but I made sure to have all required cell mechanism were compiled and the nrnmech.dll file is in the same directory.

Another phenomenon I observed was that the "dlopen failed -" message does not pop immediately when I execute "import neuron" or assign h = neuron.h, but after I import neuron.gui or execute load_file.

I could not figure how to solve the problem and am quite frustrated by the repeated failure to implement Python-Neuron interface on a PC. Any help or suggestions would be greatly appreciated, and any modification that would fix the bug will be golden. Thanks.
ted
Site Admin
Posts: 6299
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: [Win64][7.4][Canopy] "dlopen failed" and python crash

Post by ted »

Was the hoc file present in the working directory, i.e. the directory you were in when you started Python?
CYUlysses
Posts: 8
Joined: Mon Apr 06, 2015 12:54 pm

Re: [Win64][7.4][Canopy] "dlopen failed" and python crash

Post by CYUlysses »

ted wrote:Was the hoc file present in the working directory, i.e. the directory you were in when you started Python?
Yes, all of them were in the same directory.
ted
Site Admin
Posts: 6299
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: [Win64][7.4][Canopy] "dlopen failed" and python crash

Post by ted »

Does your model use ion channels or other mechanisms (pumps, synapses) whose properties are specified by mod files?
If yes, then delete any nrnmech.dll file and all .o and .c files that are in the directory that contains your hoc files, then use mknrndll to compile the mod files, and see if that fixes your problem.
CYUlysses
Posts: 8
Joined: Mon Apr 06, 2015 12:54 pm

Re: [Win64][7.4][Canopy] "dlopen failed" and python crash

Post by CYUlysses »

ted wrote:Does your model use ion channels or other mechanisms (pumps, synapses) whose properties are specified by mod files?
If yes, then delete any nrnmech.dll file and all .o and .c files that are in the directory that contains your hoc files, then use mknrndll to compile the mod files, and see if that fixes your problem.
Hi ted, yes and I just did it, but the problem persists, with the same error messages.

Is there any other information I could provide that would potentially help you figure out the problem?
hines
Site Admin
Posts: 1687
Joined: Wed May 18, 2005 3:32 pm

Re: [Win64][7.4][Canopy] "dlopen failed" and python crash

Post by hines »

I was able to import neuron if I started Python in the bash terminal, but could not import neuron if I started the Python process elsewhere
I interpret this to mean you launched IPython or PyLab from an icon. ie. you did not use the supplied bash terminal to launch Python.
When the bash terminal starts it tries to figure out, by launching Python and doing several tests, an appropriate PYTHONHOME, PYTHONPATh, and LD_LIBRARY_PATH
so that nrniv can be successfully launched. You can see the results of these tests via:
echo $PYTHONHOME
echo $PYTHONPATH
echo $LD_LIBRARYPATH
echo $NEUROHOME
Since you are launching Python instead of nrniv to run NEURON models. you don't need this but Python does need some extra environment, i.e
NEURONHOME=/c/nrn
PYTHONPATH=/c/nrn/lib/python
When you installed NEURON you were given the choice (default unselected) to set these environment variables in the DOS context so that they would be available when not running via
bash. You can either set these variables manually in Windows or uninstall NEURON and on re-installation, select the option to set those variables. When successful, if you start a
command prompt terminal you should see values for
echo %NEURONHOME%
echo %PYTHONPATH%

With regard to h.load_file('...') interacting badly with the gui, please try the following test
from neuron import h, gui
#do the mod files load and does the NEURONMainMenu start and is usable?

At this point, is the problem that
h.load_file("filename.hoc")
hangs the gui?
If so, quit and restart python along with
from neuron import h, gui
Now use NEURONMainMenu/File/LoadHoc
and select the filename.hoc
Does it work now?
It may be that I need to return to the drawing board to figure out how to better segregate GUI commands which are supposed to be executed using a separate thread from commands
typed to the interpreter.

If I have missed the point of your problem description, please send me the code along with instructions about how to reproduce the problem. Send the zip file to michael dot hines at yale dot edu
hines
Site Admin
Posts: 1687
Joined: Wed May 18, 2005 3:32 pm

Re: [Win64][7.4][Canopy] "dlopen failed" and python crash

Post by hines »

To my surprise, when I did request the "Set DOS environment" during installation, I still had to copy all the /c/nrn/bin/*.dll to /c/nrn/lib/python/neuron
(I believe only one of those is necessary but I don't remember which one) I thought that problem had been fixed...
With that work around, launching pylab allowed a successful
from neuron import h
CYUlysses
Posts: 8
Joined: Mon Apr 06, 2015 12:54 pm

Re: [Win64][7.4][Canopy] "dlopen failed" and python crash

Post by CYUlysses »

hines wrote:To my surprise, when I did request the "Set DOS environment" during installation, I still had to copy all the /c/nrn/bin/*.dll to /c/nrn/lib/python/neuron
(I believe only one of those is necessary but I don't remember which one) I thought that problem had been fixed...
With that work around, launching pylab allowed a successful
from neuron import h
Yes, I had been able to import neuron.h after copying the dll files to the python/neuron/ folder.
hines wrote:With regard to h.load_file('...') interacting badly with the gui, please try the following test
from neuron import h, gui
#do the mod files load and does the NEURONMainMenu start and is usable?
I did it in two steps:
from neuron import h
from neuron import gui

while the import of h did not raise any errors, import of gui produced the error message "dlopen failed -"
The NEURONMainMenu did start and the buttons were responsive. When I proceeded to loading .hoc files, python crashed.
hines wrote:At this point, is the problem that
h.load_file("filename.hoc")
hangs the gui?
If so, quit and restart python along with
from neuron import h, gui
Now use NEURONMainMenu/File/LoadHoc
and select the filename.hoc
Does it work now?
I tried loading the .hoc files via NEURONMainMenu/File/LoadHoc, but still got the python to crash.


I will send the relevant code to your mailbox shortly. Thanks for your help.
hines
Site Admin
Posts: 1687
Joined: Wed May 18, 2005 3:32 pm

Re: [Win64][7.4][Canopy] "dlopen failed" and python crash

Post by hines »

I will send the relevant code to your mailbox shortly.
Have not received email from you.
CYUlysses
Posts: 8
Joined: Mon Apr 06, 2015 12:54 pm

Re: [Win64][7.4][Canopy] "dlopen failed" and python crash

Post by CYUlysses »

hines wrote:
I will send the relevant code to your mailbox shortly.
Have not received email from you.
I did send an email titled "Code for forum thread "'[Win64][7.4][Canopy] "dlopen failed" and python crash'"" on July 3rd at 9.m., with a zip file. Could it be that the title or the zip file caused it be blocked by the email system?

Regardless, I just sent the email again. Hope it can get through this time.
hines
Site Admin
Posts: 1687
Joined: Wed May 18, 2005 3:32 pm

Re: [Win64][7.4][Canopy] "dlopen failed" and python crash

Post by hines »

I have it now. Will get back to you.
hines
Site Admin
Posts: 1687
Joined: Wed May 18, 2005 3:32 pm

Re: [Win64][7.4][Canopy] "dlopen failed" and python crash

Post by hines »

It may be that I need to return to the drawing board to figure out how to better segregate GUI commands which are supposed to be executed using a separate thread from commands
typed to the interpreter.
I've quietly updated the 7.4 distribution to fix the gui hanging problem. ie. see
http://www.neuron.yale.edu/hg/neuron/nr ... 37f30b6c13

As a test from the mingw bash shell try

Code: Select all

cd c:/nrn/demo
python
from neuron import h, gui
h.load_file("demo.ses") #now it does not hang
h.nrn_load_dll("release/nrnmech.dll") # if you run one of the demos that needs special mechanisms.
Note that

Code: Select all

nrngui -python
from neuron import gui
will still hang the gui because the nrngui script loads a file that maps a window prior to import of the python gui module
Post Reply