Python cannot import neuron library on Windows install

Post Reply
pascal
Posts: 109
Joined: Thu Apr 26, 2012 11:51 am

Python cannot import neuron library on Windows install

Post 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'
ted
Site Admin
Posts: 6303
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: Python cannot import neuron library on Windows install

Post by ted »

Uninstall NEURON, then reinstall it.
pascal
Posts: 109
Joined: Thu Apr 26, 2012 11:51 am

Re: Python cannot import neuron library on Windows install

Post by pascal »

Uninstalled, reinstalled, restarted...still the exact same error message.
pascal
Posts: 109
Joined: Thu Apr 26, 2012 11:51 am

Re: Python cannot import neuron library on Windows install

Post 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.
ted
Site Admin
Posts: 6303
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: Python cannot import neuron library on Windows install

Post 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.
patoorio
Posts: 82
Joined: Wed Jan 30, 2008 12:46 pm

Re: Python cannot import neuron library on Windows install

Post by patoorio »

Hi,

I am having the same issue with my Python/Windows installation:

Code: Select all

from neuron import h
Traceback (most recent call last):

  File c:\nrn\lib\python\neuron\__init__.py:135
    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):

  Cell In[1], line 1
    from neuron import h

  File c:\nrn\lib\python\neuron\__init__.py:137
    import neuron.hoc

ModuleNotFoundError: No module named 'neuron.hoc'
I uninstalled everything, then installed Python (miniconda) and finally Neuron. But the error arised again.
Looking at the C:\nrn\lib\python\neuron folder, I noticed the following files:

Code: Select all

hoc.cp37-win_amd64.pyd
hoc.cp38-win_amd64.pyd
hoc.cp39-win_amd64.pyd
hoc.cp310-win_amd64.pyd
hoc.cp311-win_amd64.pyd
But no 'cp312' file. However, I am using Python 3.12. Is it possible that the current version of Neuron is not meant to work with Python 3.12? (although under the Windows Subsystem for Linux it DOES run perfectly with Python 3.12).
What else can be happening? I took care of cleaning as much hidden folders and configuration files as I could before reinstalling everything.
Post Reply