Compiling NEURON under UNIX/Linux/WSL

If you got development code from the git repository

Jump to step 2 below.

If you downloaded gzipped tar files

The following instructions are suitable for most users, who just want a complete installation of NEURON i.e. including its GUI. For installation with Python as an alternative interpreter, or installation that omits NEURON's GUI, see Other options below.
1. Create a neuron directory in your home directory, put the gzipped source files in it, and expand them.
Start by opening an rxvt window, then
cd $HOME
mkdir neuron
mv iv-mm.tar.gz neuron
mv nrn-nn.tar.gz neuron
cd neuron
tar xzf iv-mm.tar.gz
tar xzf nrn-nn.tar.gz
# renaming the new directories iv and nrn makes life simpler later on
mv iv-mm iv
mv nrn-nn nrn
2. configure, make, and install InterViews
In the rxvt window,
cd iv
./configure --prefix=`pwd`
make
make install
Troubleshooting.

3. configure and make NEURON
cd ..
cd nrn
./configure --prefix=`pwd` --with-iv=$HOME/neuron/iv --with-nrnpython --with-paranrn
make
make install
Troubleshooting.

4. Test NEURON by running its "demonstration" program
./config.guess #your hostcpu is printed in the form hostcpu-vendor-osversion
# for this concrete example, we assume it is x86_64
x86_64/bin/neurondemo
Troubleshooting.

5. Update your PATH environment variable. For Linux, add the following line to the .bashrc file
source $HOME/neuron/nrnenv
and create an nrnenv file in $HOME/neuron with the contents
export IV=$HOME/neuron/iv
export N=$HOME/neuron/nrn
# for this concrete example, we assume hostcpu is x86_64
export CPU=x86_64
export PATH="$IV/$CPU/bin:$N/$CPU/bin:$PATH"

Other options

Installation with Python as an alternative interpreter

Assuming that the path to the Python interpreter is /usr/bin/python, to install with Python as an alternative interpreter, change the NEURON configure command to
./configure --prefix=`pwd` --with-iv=$HOME/neuron/iv --with-nrnpython=/usr/bin/python
(The path may be omitted if you want to use the default Python.) Other Python-related configuration options are:
--enable-pysetup=installoption
Execute 'python setup.py install installoption' as the last installation step. --disable-pysetup or an installoption of 'no' means do NOT execute 'python setup.py...' The default installoption is '--home=<prefix>'
--with-nrnpython-only
configure and make only the nrnpython folder
--with-nrnpython=desired python binary or 'dynamic'
Python interpreter can be used (default is NO) Probably need to set PYLIBDIR to find libpython... and PYINCDIR to find Python.h
--with-pyexe=desired python binary
(when --with-nrnpython=dynamic)
--disable-rx3d
Do not compile the cython translated 3-d rxd features
Then run make and make install, and you will be able to start NEURON with Python as an alternative interpreter via the command line
nrniv -python
or
nrngui -python
If instead you want to import NEURON into Python, there is one more step after make install: build and install the NEURON shared library for Python by
cd src/nrnpython
python setup.py install
This installs the neuron package to the Python site-packages directory, so it usually requires root access. If you do not have root access, you may use --prefix to place the neuron package in your home directory tree, like so:
python setup.py install --prefix=$HOME/local
This will install the neuron package to $HOME/local/lib/python/site-packages (i.e. in a subtree of your home directory). You will then have to add this directory to the PYTHONPATH environment variable:
export PYTHONPATH=$PYTHONPATH:$HOME/local/lib/python/site-packages
For more information about installing NEURON and using it with Python, see Hines, M.L., Davison, A.P. and Muller, E. NEURON and Python. Frontiers in Neuroinformatics 3:, 1, 2009.

Installation without the GUI

  • Ignore the instructions about iv*gz, export IV=..., and don't bother to add $IV/$CPU/bin to the PATH.
  • Don't bother to configure, make, and install InterViews.
  • The "configure" command for NEURON becomes ./configure --prefix=`pwd`

Installation for distributed simulations of cells or networks

There is no need to use any special configure options in order to do multithreaded execution on multicore workstations.

In order to perform distributed simulations of cells or networks (i.e. simulations in which the model is distributed across multiple processors, ranging from multicore workstations to parallel supercomputers), MPI must be installed, and the "configure" command for NEURON should include the option

--with-paranrn
For more information about configuring and using NEURON with MPI see https://www.neuron.yale.edu/neuron/static/py_doc/modelspec/programmatic/... as well as
Hines, M.L. and Carnevale, N.T.
Translating network models to parallel hardware in NEURON.
J. Neurosci. Methods 169:425-455, 2008
(preprint available from http://www.neuron.yale.edu/neuron/nrnpubs)

More explanations and complications

You may not ever need to know any of these things--but just in case  .  .  .
1. Where things are installed
The --prefix option in the configure statement controls where the installation will be placed. If you don't specify a prefix, a default installation directory is used. For InterViews this is /usr/local/iv, and for NEURON it is /usr/local/nrn
2. Where the NEURON installation looks for InterViews
This is controlled by the --with-iv option when you execute ./configure . . . in the nrn-n.n directory. If you don't specify a --with-iv, it looks first in prefix/.../iv and then in /usr/local/iv.
3. Putting things in other locations
Other configure options are also available. You can also build in a different directory than the sources, e.g. because you have different cpu's sharing the same sources, or because you desire several versions with different configure options (profiling, non-shared, code coverage, with and without Python).