Getting NEURON to run on OS X with Python support
UPDATED!
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:
http://www.macports.org/install.php
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 http://www.neuron.yale.edu/ftp/neuron/versions/v7.2/iv-17.tar.gz $ curl -O http://www.neuron.yale.edu/ftp/neuron/versions/v7.2/nrn-7.2.tar.gz
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 setup.py build $ sudo python setup.py 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.
This reminds me the time when I had TAed a course on Neuron in a class of Silicon Graphics (1995).
It took me the whole bl**dy summer just to compile Neuron on those machines.
Is it a coincidence that the same year S. Jobs is gone, installing neuron on a mac
goes from a matter of Drag and Drop to being a linux genius?
If you don’t need to use NEURON as a Python module, the disk images that you can get from http://www.neuron.yale.edu/ftp/neuron/versions/ are still drag-and-drop.
[…] Previously Online scientific Python NEURON and Python […]
Hi,
Thanks for the explanation, but in my case I’ve downloaded the file nrn-7.3.x86_64-apple-OSX10.7.dmg from the neuron website. Then I had to create a link from /Applications/NEURON-7.3/nrn/lib/python/neuron to /Library/Python/2.7/site-packages/neuron
I know this is not the best solution, but now it is working with Python 😀
Great, this worked for me. Thanks!
I had to add
sudo port select –set ipython ipython27
for it to work.
Everything was going well until I reached step 8. Build NEURON’s Python module. Then I get the following error:
python setup.py build
ImportError: No module named site
Does anyone know how to fix this or what can i possibly have done wrong?
This post is pretty outdated. I recommend following these instructions instead: https://www.neuron.yale.edu/phpBB/viewtopic.php?t=2881
Last I checked they worked fine.