Getting NEURON to run on OS X with Python support

This question has come up a number of times recently: how does one get NEURON to run with Python support on OS X.

At this time, there’s no simple way to install NEURON with Python support any more because Eilif’s package is outdated and won’t run with current EPD and XCode versions. The only way to
get a current version to run is to install from source.

1. Install MacPorts as described here:

2. Open up a terminal (Applications->Utilities->Terminal).

3. Get some useful MacPorts packages:

   $ sudo port install python27 py27-numpy py27-scipy py27-matplotlib py27-ipython

Make sure that installation completes without errors. Then, select MacPorts’ Python as your default version:

   $ sudo port select python python27

4. Download the NEURON source:

   $ cd ~
   $ mkdir neuron
   $ cd ~/neuron
   $ curl -O
   $ curl -O

5. Unpack the source code and move things into place:

   $ tar xvzf iv-17.tar.gz
   $ tar xvzf nrn-7.2.tar.gz
   $ mv iv-17 iv
   $ mv nrn-7.2 nrn

6. Build the InterViews part (it’s an antique widgets toolkit for the GUI):

   $ cd ~/neuron/iv
   $ ./configure --prefix=`pwd`
   $ make -j4
   $ make install

Note that `pwd` is surrounded by backquote characters.

7. Build NEURON

   $ cd ~/neuron/nrn
   $ ./configure --with-iv=${HOME}/neuron/iv --with-nrnpython=/opt/local/bin/python --prefix=`pwd`
   $ make -j4
   $ make install

Again, note that `pwd` is surrounded by backquote characters.

8. Build NEURON’s Python module:

   $ cd ~/neuron/nrn/src/nrnpython/
   $ python build
   $ sudo python install

9. Add NEURON’s binary directory to your path:

   $ cd ~
   $ echo "export PATH=${HOME}/neuron/nrn/x86_64/bin:\${PATH}" >> ~/.profile

10. Test the Python module:

   $ ipython --pylab

Then, at the ipython command prompt ([1]:), type:

   from neuron import gui

Which should bring up NEURON’s main menu.

N.B. Do not use the Enthought Python Distribution (EPD). Use MacPorts instead. The NEURON GUI doesn’t work properly with EPD at this time.

Post by Christoph Schmidt-Hieber.

  • Facebook
  • Twitter
  • Google Bookmarks
  • Slashdot
  • email
  • LinkedIn
  • Reddit