Issue importing NEURON into Python

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

Moderator: hines

Post Reply
maxwellphenderson
Posts: 22
Joined: Mon Mar 07, 2011 12:17 am

Issue importing NEURON into Python

Post by maxwellphenderson » Tue Oct 22, 2013 3:04 pm

Hello, I have for a long time using NEURON on my computer to run various experiments. Some of my experiments have gotten too large / taking too long, so I am attempting to install and run NEURON on a cluster of computers (Linux). I am trying to first install it on a single node of our cluster of computers and am running into some issues importing NEURON into Python.

So, using the download from source instructions, I have successfully ran the following steps (excluding interviews):

Code: Select all

cd $HOME
mkdir neuron
mv nrn-nn.tar.gz neuron
cd neuron
tar xzf nrn-nn.tar.gz
mv nrn-nn nrn
cd nrn
./configure --prefix=`pwd` --with-nrnpython=/usr/bin/python --without-iv
make
make install
cd src/nrnpython
python setup.py install --prefix=$HOME/local
export PYTHONPATH=$PYTHONPATH:$HOME/local/lib/python/site-packages
The encouraging part is that python is in the directory it is supposed to be and when I run the 'neurondemo' code while in nrn:

Code: Select all

./x86_64/bin/neurondemo
the result is :

Code: Select all

hendemd@node2:~/neuron/nrn$ ./x86_64/bin/neurondemo 
NEURON -- Release 7.3 (849:5be3d097b917) 2013-04-11
Duke, Yale, and the BlueBrain Project -- Copyright 1984-2013
See http://www.neuron.yale.edu/neuron/credits

loading membrane mechanisms from /home/hendemd/neuron/nrn/share/nrn/demo/release/x86_64/.libs/libnrnmech.so
Additional mechanisms from files
 cabpump.mod cachan1.mod camchan.mod capump.mod invlfire.mod khhchan.mod mcna.mod nacaex.mod nachan.mod release.mod
oc>
When I cd back into the directory 'neuron', and I try to run the following program:

Code: Select all

python test.py
___________
test.py
#
#
#
from neuron import *
The result is:

Code: Select all

hendemd@node2:~/neuron$ python test.py
Traceback (most recent call last):
  File "test.py", line 1, in <module>
    from neuron import *
ImportError: No module named neuron
Obviously, this code works on my normal machine, and so I am just trying isolate the issue I am having between python and NEURON. It seems (after running 'neurondemo') that NEURON was indeed successfully installed on the node, but I don't yet know why the when I call the Python program, it is not finding the neuron module.

The only error type I saw was after running:

Code: Select all

python setup.py install --prefix=$HOME/local


when several errors popped up looking like this:

Code: Select all

byte-compiling /home/hendemd/local/lib/python2.6/site-packages/neuron/rxd/geometry3d/voxelize.py to voxelize.pyc
SyntaxError: ('invalid syntax', ('/home/hendemd/local/lib/python2.6/site-packages/neuron/rxd/geometry3d/voxelize.py', 106, 70, '    x_objs = {x: [obj for obj in objects if obj.xlo < x < obj.xhi] for x in mesh.xs}\n'))
Anything you can see that would help me would be greatly appreciated!!! Thanks!!

ted
Site Admin
Posts: 5590
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: Issue importing NEURON into Python

Post by ted » Tue Oct 22, 2013 9:46 pm

Michael Hines will doubtless have the fix for this. In the meantime, if you're eager to get started, let me suggest that you try the Neuroscience Gateway Portal http://www.nsgportal.org/

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

Re: Issue importing NEURON into Python

Post by hines » Thu Oct 24, 2013 6:53 am

It might be that all you need is
export PYTHONPATH=$HOME/local/lib/python

By the way. The 'make install' step of the NEURON build now automatically executes
python setup.py install --prefix=<prefix>
where the prefix is where you specified in the nrn/configure command. If you use that then you would need
export PYTHONPATH=<prefix>/lib/python

maxwellphenderson
Posts: 22
Joined: Mon Mar 07, 2011 12:17 am

Re: Issue importing NEURON into Python

Post by maxwellphenderson » Thu Oct 24, 2013 11:32 am

Ah, I think it came down to a silly issue with my PYTHONPATH after all! Every time I ssh into a node, my PYTHONPATH got wiped (because apparently I didn't set it in my profile file). Thanks for the help, everything looks like it is working great now! :)

Post Reply