Compiling Neuron under macOS

Here is an excellent set of instructions for users of El Capitan, and it may contain hints that are useful if you're running an earlier version of OS X:


The following instructions assume that you are compiling for OSX 10.9 (Mavericks) or later, including macOS, and want to be able to:

  • use NEURON from the command line or through the macOS GUI
  • use Python as an alternative interpreter
  • run parallelized simulations under MPI in order to speed up embarrassingly parallel problems, or exeucte simulations of networks or individual cells that are distributed over multiple processors

Some of these instructions are based on recommendations from other Mac users who have compiled NEURON under macOS. Please let us know if you have additional suggestions.

In the following steps, you're going to use the Terminal application a lot. If it isn't in your Dock already, open /Applications/Utilities, then find Terminal and drag it to the Dock.

I. Installing prerequisites

To install NEURON from source code, you will need the following:


The most convenient way to put GCC on your Mac is to execute the following in a terminal window:

  xcode-select --install

When prompted, click "install" and then "agree" to the license.




Download and install Git from

autoconf, automake, and libtool

1. Download the most recent source code for autoconf, automake, and libtool from


2. Execute these commands in a terminal window

  mkdir ~/local ~/local/src
  export PATH=$HOME/local/bin:$PATH


3. From that same terminal, expand autoconf, then cd to the root of autoconf's source code tree and install it.

  cd ~/local/src
  tar xzf ~/Downloads/autoconf*.gz
  cd autoconf*
  ./configure --prefix=$HOME/local
  make install

4. Repeat step 3 for automake, then for libtool.


5. Now see if ~/.profile already exists. If it does, add these lines to it:

  echo now executing ~/.profile
  export PATH=$HOME/local/bin:$PATH

If ~/.profile does not already exist, create one and put those lines in it.


XQuartz provides an X11 window server.

Download and install the most recent XQuartz dmg from The installer will prompt you to log off, then back on, to make XQuartz your default X11 server. Make sure the "reopen windows when you log back in" box is checked, so your terminal and these instructions will reappear when you log back in.


In the terminal, execute this command:

  defaults write org.macosforge.xquartz.X11 wm_ffm -bool true

That will enable single click action so you can click on a button in a window without first having to click on the window to make it active.

To verify that this worked, execute this command

  defaults read | grep ffm

and look for this output:

  "wm_ffm" = 1

Open MPI

If you plan to run parallel simulations under MPI on your Mac, you'll need to download and install the tar.gz file for the latest stable release of Open MPI from Expand the tar.gz file, then install openmpi.

  cd ~/local/src
  tar xzf ~/Downloads/openmpi*.gz
  cd openmpi*
  ./configure --prefix=$HOME/local
  make install

II. Installing InterViews and NEURON.

After you get to this point, the rest is pretty easy.


A. Set up folders for the NEURON application so that the graphical icons will work and Python will work when desired.

  export IDIR=/Applications/NEURON-7.5
  mkdir $IDIR
  mkdir $IDIR/nrn
  mkdir $IDIR/iv

B. Get the source code for InterViews and NEURON

  mkdir ~/neuron
  cd ~/neuron
  git clone
  git clone

C. Install InterViews

  cd iv
  sh ./
  ./configure --prefix=$IDIR/iv
  make install

D. Install NEURON

  cd ../nrn
  sh ./
  ../nrn/configure --prefix=$IDIR/nrn --with-iv=$IDIR/iv --with-nrnpython=dynamic --with-paranrn=dynamic
  make install

E. Create a nrnenv in $HOME/neuron/ with these contents:

  export IV=$IDIR/iv
  export N=$IDIR/nrn
  export CPU=x86_64
  export PATH=$IV/$CPU/bin:$N/$CPU/bin:$PATH

and add the following lines to your ~/.profile

  export LD_LIBRARY_PATH=$HOME/local/lib/
  source ~/neuron/nrnenv

Your complete ~/.profile should now look like this:

  echo now executing ~/.profile
  export PATH=$HOME/local/bin:$PATH
  export LD_LIBRARY_PATH=$HOME/local/lib/
  source ~/neuron/nrnenv

F. Build the icons for GUI use.

  cd $HOME/neuron/nrn
  make after_install

make after_install does the following things:

  • creates the icons
  • strips the executables, making them smaller but more difficult to use with gdb
  • creates neurondemo

The executables to be stripped can be found by examining nrn/src/mac/ for the lines that contain strip. You can prevent stripping by defining a strip script that is null before executing make. Once stripped, however, NEURON has to be rebuilt in order to generate a version that is not stripped.


G. If you are developer and want to prepare a packaged version of NEURON, build a dmg.

  make dmg

This command outputs a message to the terminal that tells where the dmg was created. The default location is $HOME.

III. Post-installation testing.

Before proceeding, make sure your ~/.profile contains the lines described above (see "Your complete ~/.profile should now look like this:").

Log out, then log back in, so your ~/.profile takes effect.


A. Try running these commands from the command line:


You might also want to try double clicking the program icons in the /Applications/NEURON-7.5 folder.


B. Try running demonstrations from the parallel examples folder on the command line.

  cd ~/neuron/nrn/src/parallel
  mpirun -n 4 $N/$CPU/bin/nrniv -mpi test0.hoc
  mpirun -n 4 $N/$CPU/bin/nrniv -mpi

Example output:

  $ mpirun -n 4 $N/$CPU/bin/nrniv -mpi test0.hoc
  NEURON -- VERSION 7.5 master (2cbd3b1) 2017-09-08
  Duke, Yale, and the BlueBrain Project -- Copyright 1984-2016
  I am 3 of 4
  I am 2 of 4
  I am 0 of 4
  I am 1 of 4
  $ mpirun -n 4 $N/$CPU/bin/nrniv -mpi
  NEURON -- VERSION 7.5 master (2cbd3b1) 2017-09-08
  Duke, Yale, and the BlueBrain Project -- Copyright 1984-2016
  I am 1 of 4
  I am 2 of 4
  I am 3 of 4
  I am 0 of 4

C. Verify that NEURON can be used via the macOS GUI.

Installing NEURON places the mknrndll and nrngui icons in the Applications/NEURON-7.5 folder. For the sake of convenience, you may want make these icons more accessible by dragging and dropping them onto the dock bar.

The standard way to use NEURON with the macOS GUI interface is:

  1. Compile any mod files by dragging and dropping the folder that contains them onto the mknrndll icon. mod files are usually the top level folder of an archive, but sometimes they're in a subfolder.
  2. Launch NEURON by dragging and dropping an initialization script onto the nrngui icon. The initialization script is typically called init.hoc or mosinit.hoc.

To test this, we downloaded a random model NEURON model from ModelDB ( and did the following:

  • extract the zip file
  • drag and drop the ca3-synresp folder onto the mknrndll icon
  • drag and drop the mosinit.hoc file onto the nrngui icon

The model ran successfully.

IV. Modifying NEURON's appearance.

You can change the GUI's appearance by editing /Applications/NEURON-7.5/nrn/share/nrn/lib/nrn.defaults

It would be a good idea to make a copy first, so you can go back to the original if you like.

  cd /Applications/NEURON-7.5/nrn/share/nrn/lib/
  cp nrn.defaults nrn.defaults.orig

For example, you might want to change the default font by changing

  *font: *helvetica-medium-r-normal*--14*


  *font: *helvetica-bold-r-normal*--14*

Then run neurondemo to see the difference.