Page 1 of 1

Python cannot import neuron library on Windows install

Posted: Wed Jul 26, 2023 5:28 pm
by pascal
I'm having trouble installing NEURON 8.2 on Windows 11. I installed NEURON 8.2 using the installer from the website, then installed Anaconda. When I open Python and type from neuron import h, I get this:

Traceback (most recent call last):
File "c:\nrn\lib\python\neuron\__init__.py", line 135, in <module>
from . import hoc
ImportError: cannot import name 'hoc' from partially initialized module 'neuron' (most likely due to a circular import) (c:\nrn\lib\python\neuron\__init__.py)

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 137, in <module>
import neuron.hoc
ModuleNotFoundError: No module named 'neuron.hoc'

Re: Python cannot import neuron library on Windows install

Posted: Wed Jul 26, 2023 8:50 pm
by ted
Uninstall NEURON, then reinstall it.

Re: Python cannot import neuron library on Windows install

Posted: Thu Jul 27, 2023 3:54 pm
by pascal
Uninstalled, reinstalled, restarted...still the exact same error message.

Re: Python cannot import neuron library on Windows install

Posted: Wed Aug 09, 2023 2:06 pm
by pascal
All right, finally got it working. I uninstalled both NEURON and Anaconda. I then re-installed them, but installed Anaconda first, and NEURON second. (Before, the order was reversed.) I'm not sure why, but the order of installation seemed to matter, at least in my case.

Re: Python cannot import neuron library on Windows install

Posted: Wed Aug 09, 2023 3:12 pm
by ted
Thanks for the followup on that. I always adivse users to install Python first, then NEURON. The fact that you had to uninstall both, then install Python, and finally NEURON, doubtless contains a clue . . . if we're smart enough to figure out what it might be.