NEURON and PYTHON on Mac

NeuroRhythms
Posts: 18
Joined: Mon Aug 13, 2012 7:29 pm

NEURON and PYTHON on Mac

Post by NeuroRhythms »

Forgive me if this all very naive

I have been trying to install NEURON and use it as a module in Python following the instructions in the Frontiers paper and the Andrew Davison online notes, here: http://www.davison.webfactional.com/not ... on-python/

Whenever I want to configure neuron it gives me an error with this prompt:

Code: Select all

Examine config.log to see error details. Something wrong with
	PYLIB=-u _PyMac_Error Python.framework/Versions/2.7/Python
or
	PYLIBDIR=
or
	PYLIBLINK=-u _PyMac_Error Python.framework/Versions/2.7/Python
or
	PYINCDIR=/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7

I have found this link on the forum: http://www.neuron.yale.edu/phpbb/viewto ... f=2&t=1493

but I have not found it particularly useful. From my understanding my computer is unable to find the appropriate libraries to do anything with this. I have installed python using the .dmg binary that is on the web. Is this my problem? I have used the code from that second URL to see if that would make a difference and it does not. Do I simply not have the appropriate developers tools?

Thanks.
hines
Site Admin
Posts: 1600
Joined: Wed May 18, 2005 3:32 pm

Re: NEURON and PYTHON on Mac

Post by hines »

Are you using Lion or Mountain Lion. if so then try the following. Download
http://www.neuron.yale.edu/ftp/neuron/v ... 10.7.4.dmg
and drag NEURON-7.3 to /Applications. Then start a terminal window and
export PYTHONPATH=/Applications/NEURON-7.3/nrn/lib/python

then, does the following work?
python
import neuron
NeuroRhythms
Posts: 18
Joined: Mon Aug 13, 2012 7:29 pm

Re: NEURON and PYTHON on Mac

Post by NeuroRhythms »

I'm using Snow Leopard, Python 2.7, and NEURON 7.2

Should it matter?
NeuroRhythms
Posts: 18
Joined: Mon Aug 13, 2012 7:29 pm

Re: NEURON and PYTHON on Mac

Post by NeuroRhythms »

So I downloaded the old 7.2 binary for Mac placed it in Applications. I set up the env variable and it does not work.
hines
Site Admin
Posts: 1600
Joined: Wed May 18, 2005 3:32 pm

Re: NEURON and PYTHON on Mac

Post by hines »

It is often the case that programs built on newer osx versions do not work on older osx versions because
of changes to the system libraries. (new osx system libraries have compatibility stubs for old apis so programs
built on older osx versions are fine on newer versions). Also, it just happens to be the case that the
Lion/MountainLion version I suggested earlier has the new feature that it was built with the final step
python setup.py install --home=/Applications/NEURON-7.3/nrn
and so was ready to use as an extension module with merely the PYTHONPATH I suggested.
Earlier versions of the dmg's did not do this.

Anyway, now that you mentioned snow leopard, I need to ask. Do you have an i686 or an x86_64 bit machine?
If x86_64, and you launch python, is it a 32 bit or 64 bit program? With those answers, I can recommend a
configure line to build NEURON that should do the trick for you.
hines
Site Admin
Posts: 1600
Joined: Wed May 18, 2005 3:32 pm

Re: NEURON and PYTHON on Mac

Post by hines »

I just uploaded
http://www.neuron.yale.edu/ftp/neuron/v ... 10.6.8.dmg
which is a 32 bit version using carbon (instead of x11 which would be required if it was a 64 bit version) and built
on snow leopard.

It was built in $HOME/neuron/nrnalphacarbon using
/Users/michaelhines/neuron/nrn/configure '--prefix=/Applications/NEURON-7.3/nrn' '--with-iv=/Applications/NEURON-7.3/iv' '--enable-carbon' '--with-nrnpython=dynamic' 'CFLAGS=-arch i386 -g -O2' 'CXXFLAGS=-arch i386 -g -O2' '--with-paranrn=dynamic'

make
make install
make after_install
export IDIR=/Applications/NEURON-7.3
(cd src/nrnpython ; python setup.py install --home=$IDIR/nrn )
make dmg
make alphadist

On my Model Name: iMac
Model Identifier: iMac4,1
Processor Name: Intel Core Duo
I am able to, in a terminal window, and in my home directory:
export PYTHONPATH=/Applications/NEURON-7.3/nrn/lib/python
python
import neuron


michael-hiness-imac:~ michaelhines$ python
Python 2.6.1 (r261:67515, Jun 24 2010, 21:47:49)
[GCC 4.2.1 (Apple Inc. build 5646)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import neuron
NEURON -- VERSION 7.3 (736+:19ad148877ff+) 19ad148877ff
Duke, Yale, and the BlueBrain Project -- Copyright 1984-2012
See http://www.neuron.yale.edu/credits.html

>>>

Note that because it was configured --with-nrnpython=dynamic, the neuron extension should work with any python from 2.5 to 2.7.
NeuroRhythms
Posts: 18
Joined: Mon Aug 13, 2012 7:29 pm

Re: NEURON and PYTHON on Mac

Post by NeuroRhythms »

I have a 64 bit machine and I am running a 64 bit python.

For the record I did this.

Code: Select all

import struct
(8*struct.calcsize("P"))
within Python to get that.
hines
Site Admin
Posts: 1600
Joined: Wed May 18, 2005 3:32 pm

Re: NEURON and PYTHON on Mac

Post by hines »

If you have the latest mercurial repository version or a recent tar.gz file such as
http://www.neuron.yale.edu/ftp/neuron/v ... 733.tar.gz
then you can follow the instructions near the end of the nrn/macosxconf.sh file
in regard to snow leopard.
NeuroRhythms
Posts: 18
Joined: Mon Aug 13, 2012 7:29 pm

Re: NEURON and PYTHON on Mac

Post by NeuroRhythms »

Sorry, but if you open that tar.gz you are supposed to find a nrn folder?
hines
Site Admin
Posts: 1600
Joined: Wed May 18, 2005 3:32 pm

Re: NEURON and PYTHON on Mac

Post by hines »

nrn73
NeuroRhythms
Posts: 18
Joined: Mon Aug 13, 2012 7:29 pm

Re: NEURON and PYTHON on Mac

Post by NeuroRhythms »

This is the contents of the newly unpacked folder

Code: Select all

COPYING			config.sub		missing
INSTALL			configure		nmodlconf.h.in
Makefile.am		configure.in		nrnconf.h.in
Makefile.in		depcomp			nrnrpm.spec.in
README			extend_depcomp.sh	nrnversion.sh
aclocal.m4		hg2nrnversion_h.sh	share
bin			install-sh		src
build.sh		installunix.html	ylwrap
config.guess		ltmain.sh
config.h.in		m4
hines
Site Admin
Posts: 1600
Joined: Wed May 18, 2005 3:32 pm

Re: NEURON and PYTHON on Mac

Post by hines »

It is always a surpise when a file in the repository is not in the distribution tar.gz file. Look at
http://www.neuron.yale.edu/hg/neuron/nr ... osxconf.sh
NeuroRhythms
Posts: 18
Joined: Mon Aug 13, 2012 7:29 pm

Re: NEURON and PYTHON on Mac

Post by NeuroRhythms »

Ok so I changed the configure statements as is shown in the .sh file. I get to the part where I need to use the setup.py file. I get this error.

Code: Select all

matt-lewiss-macbook-pro-2:nrnpython Matt$ python setup.py install
  File "setup.py", line 71
    = [ epre+libdirs[0],epre+libdirs[1] ],
    ^
SyntaxError: invalid syntax
matt-lewiss-macbook-pro-2:nrnpython Matt$ 
This is different than the error reported here:

http://www.neuron.yale.edu/phpbb/viewto ... f=2&t=1493
NeuroRhythms
Posts: 18
Joined: Mon Aug 13, 2012 7:29 pm

Re: NEURON and PYTHON on Mac

Post by NeuroRhythms »

Ok well I removed the comma and changed it to a + sign. Then I got the error about about the locations not being the same.
hines
Site Admin
Posts: 1600
Joined: Wed May 18, 2005 3:32 pm

Re: NEURON and PYTHON on Mac

Post by hines »

The line is supposed to be commented out by configure and should appear as
#extra_link_args = [ epre+libdirs[0],epre+libdirs[1] ],
It is not clear to me yet how configure on your machine evaded the section in nrn/m4/nrnpython.m4
setup_extra_link_args=extra_link_args
case "$host_os" in
darwin*)
setup_extra_link_args='#extra_link_args'
;;
esac

I presume you made the locations the same and it now works. I suppose the easiest fix for me is to remove
the test but I'm quite confused how they can be different if the same python is being used to build neuron and
also execute setup.py
Post Reply