[Win64][7.4][Canopy] "dlopen failed" and python crash
Moderator: hines
[Win64][7.4][Canopy] "dlopen failed" and python crash
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.
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.
-
- 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
Was the hoc file present in the working directory, i.e. the directory you were in when you started Python?
Re: [Win64][7.4][Canopy] "dlopen failed" and python crash
Yes, all of them were in the same directory.ted wrote:Was the hoc file present in the working directory, i.e. the directory you were in when you started Python?
-
- 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
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.
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.
Re: [Win64][7.4][Canopy] "dlopen failed" and python crash
Hi ted, yes and I just did it, but the problem persists, with the same error messages.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.
Is there any other information I could provide that would potentially help you figure out the problem?
Re: [Win64][7.4][Canopy] "dlopen failed" and python crash
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.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
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
Re: [Win64][7.4][Canopy] "dlopen failed" and python crash
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
(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
Re: [Win64][7.4][Canopy] "dlopen failed" and python crash
Yes, I had been able to import neuron.h after copying the dll files to the python/neuron/ folder.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
I did it in two steps: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?
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.
I tried loading the .hoc files via NEURONMainMenu/File/LoadHoc, but still got the python to crash.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 will send the relevant code to your mailbox shortly. Thanks for your help.
Re: [Win64][7.4][Canopy] "dlopen failed" and python crash
Have not received email from you.I will send the relevant code to your mailbox shortly.
Re: [Win64][7.4][Canopy] "dlopen failed" and python crash
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?hines wrote:Have not received email from you.I will send the relevant code to your mailbox shortly.
Regardless, I just sent the email again. Hope it can get through this time.
Re: [Win64][7.4][Canopy] "dlopen failed" and python crash
I have it now. Will get back to you.
Re: [Win64][7.4][Canopy] "dlopen failed" and python crash
I've quietly updated the 7.4 distribution to fix the gui hanging problem. ie. seeIt 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.
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.
Code: Select all
nrngui -python
from neuron import gui