Neuron + Python on Mac OS-X, Enthought Python distribution

When Python is the interpreter, what is a good
design for the interface to the basic NEURON
concepts.

Moderator: hines

Post Reply
pbmanis
Posts: 3
Joined: Thu Jun 14, 2007 9:02 pm
Location: UNC Chapel Hill
Contact:

Neuron + Python on Mac OS-X, Enthought Python distribution

Post by pbmanis » Tue Feb 10, 2009 10:09 pm

I have been using the Enthought Python distribution - which includes matplotlib (pylab), numpy, scipy, and a lot of other stuff that makes it convenient. A free distribution is available for academic use.
However it didn't want to cooperate with the standard nrnpython install, so here are my notes for making it work - there were only 2 small changes, but this might help someone.

Installing nrn with python on mac os x (version 7.0 of NEURON).

1. compile from source... otherwise the python include library doesn't seem to get found***. The default ./configure yields:
get_config_var('LINKFORSHARED') '-u _PyMac_Error Python.framework/Versions/4.1.30101/Python'
checking if python include files and libraries work... configure: error: could not run a test that used the python library.
Examine config.log to see error details. Something wrong with
PYLIB=-u _PyMac_Error Python.framework/Versions/4.1.30101/Python
or
PYLIBDIR=
or
PYLIBLINK=-u _PyMac_Error Python.framework/Versions/4.1.30101/Python
or
PYINCDIR=/Library/Frameworks/Python.framework/Versions/4.1.30101/include/python2.5

(I have seen this on 2 different systems).

Per Hines on 4/12/08, at neuron bb with python, use the following to configure:

/Users/hines/neuron/nrn/configure '--prefix=/Applications/NEURON-6.2/nrn' '--srcdir=/Users/hines/neuron/nrn' '--with-iv=/Applications/NEURON-6.2/iv' '--enable-carbon' '--with-nrnpython' '--enable-UniversalMacBinary' PYLIBLINK='-framework Python' PYLIB='-framework Python'

except that I used (nrn is on the desktop; your directories might be different):

/Users/myhomedir/Desktop/nrn-7.0/configure '--prefix=/Applications/NEURON-7.0/nrn' '--srcdir=/Users/myhomedir/Desktop/nrn-7.0' '--with-iv=/Applications/NEURON-7.0/iv' '--enable-carbon' '--with-nrnpython' '--enable-UniversalMacBinary' PYLIBLINK='-framework Python' PYLIB='-framework Python'

Now configure completes without errors.

2. make and install as usual

3. Then we have to jump into src/nrnpython and do the setup, but "python setup.py install" fails:

lytle:nrnpython pbmanis$ python setup.py install
Error:
NEURON configure time python: /Library/Frameworks/Python.framework/Versions/Current/bin/python
Python presently executing setup.py: /Library/Frameworks/Python.framework/Versions/4.1.30101/Resources/Python.app/Contents/MacOS/Python
These do not match, and the should!

(yes, there is a typo in setup.py: (they should!")

So edit setup.py with the "presently executing" replacing nrnpython_exec as follows:
# nrnpython_exec = "/Library/Frameworks/Python.framework/Versions/Current/bin/python" # old
nrnpython_exec = "/Library/Frameworks/Python.framework/Versions/4.1.30101/Resources/Python.app/Contents/MacOS/Python"

(That line should point to whatever is "presently executing setup.py" - it could be different.)

It works!

--Paul

***Note: It may seem obvious, but make sure you compile Interviews and Neuron for the same platform (e.g., '--enable-UniversalMacBinary' ). I forgot to do this with Interviews on a clean install the other day, and spent a few hours trying to figure out where the build went wrong.

nsteinme
Posts: 2
Joined: Fri Jan 01, 2010 5:43 pm

Re: Neuron + Python on Mac OS-X, Enthought Python distribution

Post by nsteinme » Fri Jan 01, 2010 6:26 pm

Hi, just wanted to say thank you for posting this information - I needed it to complete the installation correctly, and can't even begin to wonder how much of my time I would have wasted trying to figure out the bit about editing "setup.py". You saved my day!

Prokopiou

Re: Neuron + Python on Mac OS-X, Enthought Python distributi

Post by Prokopiou » Mon May 07, 2012 11:23 am

Hello,

Im also trying to put together Enthought (Version 7.2) and Neuron on a Mac (Version 10.7.3). I tried using what is said in this post but it doesn't seem to work. Then I noticed the post is kind of old so is there a update of this procedure that must be followed with newer versions?

This is the output I get if it is of any help:

Code: Select all

yn1064-103:~ andreasprokopiou$ /Users/andreasprokopiou/Desktop/nrn-7.2/configure '--prefix=/Applications/NEURON-7.2/nrn' '--srcdir=/Users/andreasprokopiou/Desktop/nrn-7.2' '--with-iv=/Applications/NEURON-7.2/iv' '--enable-carbon' '--with-nrnpython' '--enable-UniversalMacBinary' PYLIBLINK='-framework Python' PYLIB='-framework Python'
configure: WARNING: unrecognized options: --enable-carbon
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /Users/andreasprokopiou/Desktop/nrn-7.2/install-sh -c -d
checking for gawk... no
checking for mawk... no
checking for nawk... no
checking for awk... awk
checking whether make sets $(MAKE)... yes
checking build system type... x86_64-apple-darwin11.3.0
checking host system type... x86_64-apple-darwin11.3.0
checking for style of include used by make... GNU
checking for g++... g++
checking whether the C++ compiler works... no
configure: error: in `/Users/andreasprokopiou':
configure: error: C++ compiler cannot create executables
See `config.log' for more details

dyn1064-103:~ andreasprokopiou$ gcc -v
Using built-in specs.
Target: i686-apple-darwin11
Configured with: /private/var/tmp/llvmgcc42/llvmgcc42-2336.9~22/src/configure --disable-checking --enable-werror --prefix=/Applications/Xcode.app/Contents/Developer/usr/llvm-gcc-4.2 --mandir=/share/man --enable-languages=c,objc,c++,obj-c++ --program-prefix=llvm- --program-transform-name=/^[cg][^.-]*$/s/$/-4.2/ --with-slibdir=/usr/lib --build=i686-apple-darwin11 --enable-llvm=/private/var/tmp/llvmgcc42/llvmgcc42-2336.9~22/dst-llvmCore/Developer/usr/local --program-prefix=i686-apple-darwin11- --host=x86_64-apple-darwin11 --target=i686-apple-darwin11 --with-gxx-include-dir=/usr/include/c++/4.2.1
Thread model: posix
gcc version 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.9.00)

Thanks,
Andreas.

hines
Site Admin
Posts: 1575
Joined: Wed May 18, 2005 3:32 pm

Re: Neuron + Python on Mac OS-X, Enthought Python distributi

Post by hines » Sun Jul 08, 2012 10:25 am

The following are my latest notes about installing under Mac osx 10.7. Though not directly for enthought, they are probably relevant and I believe there is a good chance it would
work without change for enthought as long as the dynamic loader finds the enthought python library first. The intention of all this was to get a NEURON dmg that would be
generic for any Python and also for MPI whether or not Python or MPI was installed. I have not succeeded in this for MPI yet. ie. if MPI is desired, one needs to build from the
sources with openmpi already installed and in the PATH.

# assume InterViews sources in $HOME/neuron/iv
# assume NEURON sources in $HOME/neuron/nrn
# assume that you are using a Terminal window

SOFT=$HOME/neuron

# if configure does not exist in $SOFT/iv or $SOFT/nrn, then in those directories, execute
# sh build.sh

nver=`./nrnversion.sh`
echo $nver
exit 0

IDIR="/Applications/NEURON-${nver}"


#for Lion osx 10.7
# 64 bit, icons work, python available. If desire MPI then should install openmpi first.

# xcode command line tools must be installed. Two ways to do this.
#First way: From https://developer.apple.com/xcode one can get a free version
# of Xcode 4.3.3 for Lion from the Mac App Store.
# After installing, launch Xcode 4 and menu navigate to Xcode Preferences and in the popup window
# install the "Command Line Tools".
#Second way: To avoid downloading the entire Xcode4 installer, which is about 4GB in size, one can
# install the much smaller (170 MB dmg) "Command Line Tools" separately from
# https://developer.apple.com (search there for "Command Line Tools for Xcode"). You will have to login
# with your apple id.


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

cd $SOFT/nrn
../nrn/configure --prefix=$IDIR/nrn --with-iv=$IDIR/iv --with-nrnpython=dynamic
make
make install
#note:
make after_install
make dmg
#is used to create a distributed version with neurondemo and (for small dmg) stripped executables.

# if mpi desired, install openmpi, make sure mpicc and mpicxx is in your PATH and add --with-paranrn
# to the ../nrn/configure line. e.g.
# from http://www.open-mpi.org go to Download page and get the current stable release tar.gz
# after extracting, do the ./configure ; make; make install

#in order to get single click button action for x11 when entering a window,
# determine if you are using org.macosforge.xquartz.X11
# or org.x.X11 with
defaults read | grep X11
#depending on the result, then one or both of the following:
defaults write org.x.X11 wm_ffm -bool true
defaults write org.macosforge.xquartz.X11 wm_ffm -bool true

Post Reply