DLL load failed & No module named hoc error

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

Moderator: hines

Post Reply
camilhamdane
Posts: 8
Joined: Mon Aug 05, 2019 7:37 am

DLL load failed & No module named hoc error

Post by camilhamdane »

Hello there,


I am fairly new to python and Neuron, and I need to get Neuron to work alongside python for a lab project I'm starting this week. However, I cannot figure out what I am doing wrong as I cannot have neuron launched in python.

I have Python 3.7.4 32-bit, with the latest version of Neuron (7.7.2 today), installed on Windows 10.
All I did was to download the windows installer from the website, which works since I can launch Neuron by itself without any issue. But when I enter these commands in the command prompt windows :

Code: Select all

python
import neuron
this happens :

Code: Select all

>>> import neuron
Traceback (most recent call last):
  File "c:\nrn\lib\python\neuron\__init__.py", line 106, in <module>
    import hoc
ModuleNotFoundError: No module named 'hoc'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "c:\nrn\lib\python\neuron\__init__.py", line 110, in <module>
    import neuron.hoc
ModuleNotFoundError: No module named 'neuron.hoc'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "c:\nrn\lib\python\neuron\__init__.py", line 112, in <module>
    exec("import neuron.hoc%d%d as hoc" % (sys.version_info[0], sys.version_info[1]))
  File "<string>", line 1, in <module>
ImportError: DLL load failed: %1 is not a valid win32 application
I've gone through a lot of threads on this forum all day but I still have not found a working fix for this.

I tried checking the paths, and everything, from NEURONHOME to Python Path is correct, I tried installing a previous version of Neuron, I tried changing the "import hoc" line to "from neuron import hoc" inside ___init___.py but the error remains.


Thank you to anyone that took the time to read this and who will hopefully have an idea as to how to fix it.
Best regards.


UPDATE
I just figured out that at the end of the error message something about win32 is written, which got me wondering that maybe (I feel dumb) I should not be running python 32 bit on a 64 bit installation... I then installed Python 64 bit, but now I get yet another different error message:

Code: Select all

Python 3.7.4 (tags/v3.7.4:e09359112e, Jul  8 2019, 20:34:20) [MSC v.1916 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import neuron
Can't load NEURON resources from c:\nrn;/lib/nrn.def[aults]
Failed to setup nrnpy_pr
Failed to setup nrnpy_vec_math
I really don't have a clue for this one, but I'm going to keep looking tonight.
Thank you
ted
Site Admin
Posts: 6299
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: DLL load failed & No module named hoc error

Post by ted »

Code: Select all

import neuron
Good guess, but do this instead:

Code: Select all

from neuron import h
If you plan on using NEURON's GUI tools, do this

Code: Select all

from neuron import h,gui
If you intend to take advantage of its standard run time library

Code: Select all

from neuron import h
h.load_file("stdgui.hoc")
camilhamdane
Posts: 8
Joined: Mon Aug 05, 2019 7:37 am

Re: DLL load failed & No module named hoc error

Post by camilhamdane »

Dear ted, thank you for your reply.

I'm afraid I get the same error no matter the input...
I spent the last two day trying to figure out what to do, I even installed a fresh ubuntu VM to try and install it on there but I got yet other errors.
The solution I took was to download the wonderful NeuroVM (viewtopic.php?t=4113) posted a few days ago, and I can finally use Neuron :)
Post Reply