Page 1 of 1

ImportError when importing the unit 'nA' from neuron.units

Posted: Wed Jul 12, 2023 10:22 pm
by TrZ
Hello,
After I run a section of code in a Google Colab notebook I am getting an error that reads: ImportError: cannot import name 'nA' from 'neuron.units' (/usr/local/lib/python3.10/dist-packages/neuron/units.py)
-Somehow I cannot access any subdirectory in the folder /usr/local/ to attempt to find the neuron.units submodule. When I run NEURON through Python running from my terminal, the files from the NEURON that runs are in this other directory instead: /Users/tristan/Library/Python/3.8/lib/python/site-packages/neuron

The code section I have written on my Google Colab notebook is below, where the 2nd line causes the error.

from neuron import h
from neuron.units import mV, ms, μm, nA
h.load_file("stdrun.hoc")

Can someone help me resolve this issue? I am using a MacOS Monterey version 12.0.1. Thx

Re: ImportError when importing the unit 'nA' from neuron.units

Posted: Thu Jul 13, 2023 1:16 pm
by ted
Yes, nA is not defined in neuron.units, and merely adding
nA = 1
to the list of "NEURON's default units" in the units.py file fixes the problem.

On my machine, units.py is in ~/.local/lib/python3.8/site-packages/neuron