Trying to get python with OS X working

Post Reply
adamimos
Posts: 45
Joined: Mon Jan 25, 2010 4:49 pm

Trying to get python with OS X working

Post by adamimos »

Hey everyone,

I'm just starting with NEURON and I installed from dmg and everything works fine. I am now trying to get NEURON working as a module within python. When I try to install from source I get a bunch of different errors depending on what I try. I tried this to install IV:

Code: Select all

 IDIR=/Applications/NEURON-n.n
./configure --prefix=$IDIR/iv --enable-carbon
  make
and i get this:

Code: Select all

Making all in src
Making all in lib
 g++ -DHAVE_CONFIG_H -I. -I. -I../include -g -O2 -DMAC=1 -Dcarbon=1 -DSYSV=1 -c IV-Mac/canvas.cpp  -fno-common -DPIC -o IV-Mac/.libs/canvas.o
In file included from IV-Mac/canvas.cpp:59:
../include/IV-Mac/window.h: In member function 'void MACwindow::setport()':
../include/IV-Mac/window.h:112: error: 'GetWindowPort' was not declared in this scope
../include/IV-Mac/window.h:112: error: 'SetPort' was not declared in this scope
../include/IV-Mac/window.h: In static member function 'static ivWindowRep* ivWindowRep::rc(OpaqueWindowPtr*)':
../include/IV-Mac/window.h:192: error: 'GetWRefCon' was not declared in this scope
IV-Mac/canvas.cpp: In member function 'virtual void MACcanvas::beginPaint()':
IV-Mac/canvas.cpp:331: error: 'ClipRect' was not declared in this scope
IV-Mac/canvas.cpp: In member function 'virtual ivCoord MACcanvas::width() const':
IV-Mac/canvas.cpp:405: error: 'GetWindowPort' was not declared in this scope
IV-Mac/canvas.cpp:405: error: 'GetPortBounds' was not declared in this scope
IV-Mac/canvas.cpp: In member function 'virtual ivCoord MACcanvas::height() const':
IV-Mac/canvas.cpp:419: error: 'GetWindowPort' was not declared in this scope
IV-Mac/canvas.cpp:419: error: 'GetPortBounds' was not declared in this scope
IV-Mac/canvas.cpp: In member function 'virtual ivPixelCoord MACcanvas::pwidth() const':
IV-Mac/canvas.cpp:433: error: 'GetWindowPort' was not declared in this scope
IV-Mac/canvas.cpp:433: error: 'GetPortBounds' was not declared in this scope
IV-Mac/canvas.cpp: In member function 'virtual ivPixelCoord MACcanvas::pheight() const':
IV-Mac/canvas.cpp:447: error: 'GetWindowPort' was not declared in this scope
IV-Mac/canvas.cpp:447: error: 'GetPortBounds' was not declared in this scope
IV-Mac/canvas.cpp: In member function 'virtual void MACcanvas::initClip()':
IV-Mac/canvas.cpp:518: error: 'ClipRect' was not declared in this scope
IV-Mac/canvas.cpp: In member function 'virtual void MACcanvas::push_clipping(osboolean)':
IV-Mac/canvas.cpp:534: error: 'ClipRect' was not declared in this scope
IV-Mac/canvas.cpp: In member function 'virtual void MACcanvas::pop_clipping()':
IV-Mac/canvas.cpp:557: error: 'ClipRect' was not declared in this scope
IV-Mac/canvas.cpp: In member function 'virtual void MACcanvas::clip()':
IV-Mac/canvas.cpp:605: error: 'ClipRect' was not declared in this scope
IV-Mac/canvas.cpp: In member function 'virtual void MACcanvas::stroke(const ivColor*, const ivBrush*)':
IV-Mac/canvas.cpp:922: error: 'MoveTo' was not declared in this scope
IV-Mac/canvas.cpp:924: error: 'LineTo' was not declared in this scope
IV-Mac/canvas.cpp: In member function 'virtual void MACcanvas::fill(const ivColor*)':
IV-Mac/canvas.cpp:953: error: 'OpenPoly' was not declared in this scope
IV-Mac/canvas.cpp:955: error: 'MoveTo' was not declared in this scope
IV-Mac/canvas.cpp:957: error: 'LineTo' was not declared in this scope
IV-Mac/canvas.cpp:962: error: 'ClosePoly' was not declared in this scope
IV-Mac/canvas.cpp:963: error: 'PaintPoly' was not declared in this scope
IV-Mac/canvas.cpp:964: error: 'KillPoly' was not declared in this scope
IV-Mac/canvas.cpp: In member function 'void MACcanvas::color(const ivColor*)':
IV-Mac/canvas.cpp:999: error: 'RGBForeColor' was not declared in this scope
IV-Mac/canvas.cpp:1021: error: 'PenMode' was not declared in this scope
IV-Mac/canvas.cpp:1025: error: 'PenMode' was not declared in this scope
IV-Mac/canvas.cpp: In member function 'void MACcanvas::brush(const ivBrush*)':
IV-Mac/canvas.cpp:1052: error: 'PenSize' was not declared in this scope
IV-Mac/canvas.cpp: In member function 'virtual void MACcanvas::flush()':
IV-Mac/canvas.cpp:1173: error: 'TextFont' was not declared in this scope
IV-Mac/canvas.cpp:1174: error: 'TextFace' was not declared in this scope
IV-Mac/canvas.cpp:1175: error: 'TextSize' was not declared in this scope
IV-Mac/canvas.cpp:1176: error: 'TextMode' was not declared in this scope
IV-Mac/canvas.cpp:1178: error: 'MoveTo' was not declared in this scope
IV-Mac/canvas.cpp:1179: error: 'DrawText' was not declared in this scope
IV-Mac/canvas.cpp: In member function 'virtual void MACcanvas::image(const ivRaster*, ivCoord, ivCoord)':
IV-Mac/canvas.cpp:1285: error: 'GetGWorld' was not declared in this scope
IV-Mac/canvas.cpp:1288: error: 'GetPortBitMapForCopyBits' was not declared in this scope
IV-Mac/canvas.cpp:1293: error: 'CopyBits' was not declared in this scope
make[2]: *** [IV-Mac/canvas.lo] Error 1
Making all in include
make[2]: Nothing to be done for `all'.
Making all in bin
Making all in idemo
/bin/sh ../../../libtool --mode=link g++ -g -O2 -DMAC=1 -Dcarbon=1 -DSYSV=1 -framework Carbon  -o idemo main.o ../../lib/libIVhines.la  
libtool: link: cannot find the library `../../lib/libIVhines.la' or unhandled argument `../../lib/libIVhines.la'
make[3]: *** [idemo] Error 1

I also tried:

./configure --prefix=/Users/adamimos/neuron/iv-17


and I got an error saying that X11 could not be found, though I am sure I have X11 installed...

any help would be much appreciated! (If there is a way to get NEURON working as a module in python without installing from source, that would be helpful as well).

Thanks.
selfdestructo
Posts: 32
Joined: Wed Oct 14, 2009 11:12 am

Re: Trying to get python with OS X working

Post by selfdestructo »

I made this sh.-script some time ago to install neuron as python module on 64 bit python on mac os x 10.6. Use at your own risk.

Code: Select all

#!/bin/sh                                                                                                  
#Install Neuron with InterViews and nrnpython interphase                                                   

#create a directory in home directory                                                                                        
cd $HOME
mkdir nrn64
cd nrn64

#removing old                                                                                              
#sudo rm -r /Applications/nrn71_x86_64*
#sudo rm -r /Work/LFPy/trunk/neuron/x86_64*



#Downloading bleeding edge source code
hg clone http://www.neuron.yale.edu/hg/neuron/iv
hg clone http://www.neuron.yale.edu/hg/neuron/nrn

#curl http://www.neuron.yale.edu/ftp/neuron/versions/v7.1/iv-17.tar.gz | tar xzf -
#curl http://www.neuron.yale.edu/ftp/neuron/versions/v7.1/nrn-7.1.tar.gz | tar xzf -


#tar xzf iv-17.tar.gz
#tar xzf nrn-7.1.tar.gz

#compiling and installing IV under /Applications/nrn7.1                                                    
cd iv
make distclean
sh build.sh
./configure --prefix=/Applications/nrn71_x86_64/iv \
    --build=x86_64-apple-darwin10 --host=x86_64-apple-darwin10 \
    CFLAGS='-O3 -arch x86_64 -m64 -fPIC -mfpmath=sse -msse3' CXXFLAGS='-O3 -arch x86_64 -m64 -fPIC -mfpmath=sse -msse3'


#	CFLAGS='-arch x86_64' CXXFLAGS='-arch x86_64'
#    PYLIB='-lpython' PYLIBLINK='-lpython' \
#	CFLAGS='-O3 -arch x86_64' CXXFLAGS='-O3 -arch x86_64'
#    --x-includes=/usr/X11/include/ --x-libraries=/usr/X11/lib \                                           
#    CFLAGS='-O3 -arch ppc -arch i386' CXXFLAGS='-O3 -arch ppc -arch i386'                                 
    #--with-x --x-includes=/usr/X11/include/ --x-libraries=/usr/X11/lib                                    
#--build=x86_64 --host=x86_64 \                                                                            
#--build=i386 --host=i386 \                                                                                

make
make install

#Somethings not quite right when Neuron looks for IV libraries, it doesn't look into the folder umac       
cd /Applications/nrn71_x86_64/iv
#ln -s umac/lib lib
ln -s x86_64/lib lib                                                                                      
#ln -s i386/lib lib        

#Building NEURON with InterViews, you may have to alter the path --with-nrnpython=/python-path  
cd $HOME/nrn64/nrn
make distclean
sh build.sh
./configure --prefix=/Applications/nrn71_x86_64/nrn --with-iv=/Applications/nrn71_x86_64/iv \
    --with-x --x-includes=/usr/X11/include/ --x-libraries=/usr/X11/lib/ \
    --with-nrnpython=/opt/local/Library/Frameworks/Python.framework/Versions/2.6/Resources/Python.app/Contents/MacOS/Python \
    --host=x86_64-apple-darwin10 --build=x86_64-apple-darwin10 \
    --with-paranrn \
    CFLAGS='-O3 -arch x86_64 -m64 -fPIC -mfpmath=sse -msse3' CXXFLAGS='-O3 -arch x86_64 -m64 -fPIC -mfpmath=sse -msse3' \
    PYLIB=-lpython PYLIBLINK=-lpython

#./configure --prefix=/Applications/nrn71_x86_64/nrn --with-iv=/Applications/nrn71_x86_64/iv \#
#	--with-x --x-includes=/usr/X11/include/ --x-libraries=/usr/X11/lib/ \
#    --with-nrnpython=/opt/local/Library/Frameworks/Python.framework/Versions/2.6/Resources/Python.app/Contents/MacOS/Python \
#    --host=x86_64 --build=x86_64 \ 
#    PYLIB=-lpython PYLIBLINK=-lpython
#	CFLAGS='-O3 -arch x86_64' CXXFLAGS='-O3 -arch x86_64'
#	CFLAGS='-arch x86_64' CXXFLAGS='-arch x86_64'
#    CFLAGS='-O3 -arch x86_64' CXXFLAGS='-O3 -arch x86_64'
#   --enable-UniversalMacBinary
#    CFLAGS='-O3 -arch ppc -arch i386' CXXFLAGS='-O3 -arch ppc -arch i386'                                 
#--with-x --x-includes=/usr/X11/include/ --x-libraries=/usr/X11/lib/                                       
#--with-nrnpython=/opt/local/bin/python \                                                                  
#--build=x86_64 --host=x86_64 \                                                                            
#--build=i386 --host=i386 \                                                                                

make
make install
make after_install

#You should now have a working NEURON application under Applications. Small test;                          
sudo /Applications/nrn71_x86_64/nrn/x86_64/bin/neurondemo                                                                 


#If this works, you should add /Applications/nrn7.1/nrn/x86_64/bin/ to your PATH variable.                   

#Final step is to install neuron as a python module                                                        
cd src/nrnpython
sudo /opt/local/bin/python setup.py install


#g++ -L/opt/local/lib -bundle -undefined dynamic_lookup build/temp.macosx-10.6-i386-2.6/inithoc.o -L/Applications/nrn71_x86_64/nrn/x86_64/lib -L/Applications/nrn71_x86_64/iv/x86_64/lib -lnrnpython -lnrnoc -loc -lnrniv -livoc -lmemacs -lmeschach -lneuron_gnu -lnrnmpi -lscopmath -lsparse13 -lsundials -lIVhines -lreadline -o build/lib.macosx-10.6-i386-2.6/neuron/hoc.so -Wl,-R/Applications/nrn71_x86_64/nrn/x86_64/lib -Wl,-R/Applications/nrn71_x86_64/iv/x86_64/lib

#sudo g++ -L/opt/local/lib -bundle -undefined dynamic_lookup build/temp.macosx-10.6-i386-2.6/inithoc.o -L/Applications/nrn71_x86_64/nrn/x86_64/lib -L/Applications/nrn71_x86_64/iv/x86_64/lib -lnrnpython -lnrnoc -loc -lnrniv -livoc -lmemacs -lmeschach -lneuron_gnu -lnrnmpi -lscopmath -lsparse13 -lsundials -lIVhines -lreadline -o build/lib.macosx-10.6-i386-2.6/neuron/hoc.so -Wl -R/Applications/nrn71_x86_64/nrn/x86_64/lib -Wl -R/Applications/nrn71_x86_64/iv/x86_64/lib

#sudo g++ -L/opt/local/lib -bundle -undefined dynamic_lookup build/temp.macosx-10.6-i386-2.6/inithoc.o -L/Applications/nrn71_x86_64/nrn/x86_64/lib -L/Applications/nrn71_x86_64/iv/x86_64/lib -lnrnpython -lnrnoc -loc -lnrniv -livoc -lmemacs -lmeschach -lneuron_gnu -lnrnmpi -lscopmath -lsparse13 -lsundials -lIVhines -lreadline -o build/lib.macosx-10.6-i386-2.6/neuron/hoc.so -Wl -R/Applications/nrn71_x86_64/nrn/x86_64/lib -Wl -R/Applications/nrn71_x86_64/iv/x86_64/lib
#sudo /opt/local/bin/python setup.py install

#If the above fail because python is not where you told it would be, edit the nrnpython-path               
#in setup.py to whatever it should be.                                                                     
cd $HOME

#Checking nrnpython-installation, should not return any errors
/opt/local/bin/python -c 'from pylab import *' -c 'import neuron' -c 'import LFPy'

cd Work/LFPy/trunk/neuron/
/Applications/nrn71_x86_64/nrn/x86_64/bin/nrnivmodl

#cd /Users/ehagen/Work/LFPy/trunk/neuron/
#sudo /Applications/nrn71_x86_64/nrn/x86_64/bin/nrnivmodl

cd $HOME



adamimos
Posts: 45
Joined: Mon Jan 25, 2010 4:49 pm

Re: Trying to get python with OS X working

Post by adamimos »

Thank you so much! I just had to change some very small things. It worked great!
Post Reply