What sets the sys.path for nrniv -python?

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

Moderator: hines

Post Reply
aaronmil
Posts: 35
Joined: Fri Apr 25, 2014 10:54 am

What sets the sys.path for nrniv -python?

Post by aaronmil » Thu Dec 11, 2014 4:44 pm

When I execute

Code: Select all

nrniv -python
then

Code: Select all

import sys
sys.path
i get:

Code: Select all

['', '', '', '/Users/milsteina', '/Applications/NEURON-7.3/nrn/lib/python', '/anaconda/lib', '/usr/lib/python27.zip', '/usr/lib/python2.7', '/usr/lib/python2.7/plat-darwin', '/usr/lib/python2.7/plat-mac', '/usr/lib/python2.7/plat-mac/lib-scriptpackages', '/usr/Extras/lib/python', '/usr/lib/python2.7/lib-tk', '/usr/lib/python2.7/lib-old', '/usr/lib/python2.7/lib-dynload', '/Library/Python/2.7/site-packages', '/Applications/NEURON-7.3/nrn/share/nrn/lib/python']
but when i just execute

Code: Select all

python
then

Code: Select all

import sys
sys.path
i get

Code: Select all

['', '/Users/milsteina', '/Applications/NEURON-7.3/nrn/lib/python', '/anaconda/lib', '/anaconda/lib/python27.zip', '/anaconda/lib/python2.7', '/anaconda/lib/python2.7/plat-darwin', '/anaconda/lib/python2.7/plat-mac', '/anaconda/lib/python2.7/plat-mac/lib-scriptpackages', '/anaconda/lib/python2.7/lib-tk', '/anaconda/lib/python2.7/lib-old', '/anaconda/lib/python2.7/lib-dynload', '/anaconda/lib/python2.7/site-packages', '/anaconda/lib/python2.7/site-packages/PIL', '/anaconda/lib/python2.7/site-packages/Sphinx-1.2.3-py2.7.egg', '/anaconda/lib/python2.7/site-packages/runipy-0.1.1-py2.7.egg', '/anaconda/lib/python2.7/site-packages/setuptools-7.0-py2.7.egg']
i need to be able to access the modules that are installed in the anaconda python, which seems configured correctly in my .bash_profile

aaronmil
Posts: 35
Joined: Fri Apr 25, 2014 10:54 am

Re: What sets the sys.path for nrniv -python?

Post by aaronmil » Thu Dec 11, 2014 5:13 pm

Note:
I can get around this by first executing:

Code: Select all

python
then

Code: Select all

from neuron import gui
import sys
sys.path
which then gives me the access that i need

Code: Select all

['', '/Users/milsteina', '/Applications/NEURON-7.3/nrn/lib/python', '/anaconda/lib', '/anaconda/lib/python27.zip', '/anaconda/lib/python2.7', '/anaconda/lib/python2.7/plat-darwin', '/anaconda/lib/python2.7/plat-mac', '/anaconda/lib/python2.7/plat-mac/lib-scriptpackages', '/anaconda/lib/python2.7/lib-tk', '/anaconda/lib/python2.7/lib-old', '/anaconda/lib/python2.7/lib-dynload', '/anaconda/lib/python2.7/site-packages', '/anaconda/lib/python2.7/site-packages/PIL', '/anaconda/lib/python2.7/site-packages/Sphinx-1.2.3-py2.7.egg', '/anaconda/lib/python2.7/site-packages/runipy-0.1.1-py2.7.egg', '/anaconda/lib/python2.7/site-packages/setuptools-7.0-py2.7.egg']
but i'm still curious where the other sys.path defaults come from. thanks.

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

Re: What sets the sys.path for nrniv -python?

Post by ted » Fri Dec 12, 2014 6:10 pm

First a few questions.
Are you running NEURON under MSWin, Linux, or OS X?
Did you build NEURON from source code using --with-nrnpython, or did you install from a binary distribution i.e. a dmg or rpm?

aaronmil
Posts: 35
Joined: Fri Apr 25, 2014 10:54 am

Re: What sets the sys.path for nrniv -python?

Post by aaronmil » Sat Dec 13, 2014 10:44 am

ted wrote:First a few questions.
Are you running NEURON under MSWin, Linux, or OS X?
OS X
ted wrote:Did you build NEURON from source code using --with-nrnpython?
Yes. Come to think of it, I did not install the anaconda build of python until after I had installed NEURON. Is it now hard coded to refer to the previous python?

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

Re: What sets the sys.path for nrniv -python?

Post by ted » Sat Dec 13, 2014 6:19 pm

Either that, or else some post-compilation configuration script has done something that depends on the non-anaconda python. Looking at nrn/configure, I see

Code: Select all

  --with-nrnpython=desired python binary or 'dynamic'
                          Python interpreter can be used (default is NO)
                          Probably need to set PYLIBDIR to find libpython...
                          and PYINCDIR to find Python.h
which suggests you need to throw away what you built, then do
make clean
then set the indicated environment variables, and finally
./configure . . . other options . . . --with-nrnpython=pathtodesiredpythonbinary
make
make install

But you may want to wait to see if Robert McDougal or Michael Hines have other suggestions.

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

Re: What sets the sys.path for nrniv -python?

Post by hines » Sun Dec 14, 2014 12:56 am

Did you build NEURON from source code using --with-nrnpython?
Yes. Come to think of it, I did not install the anaconda build of python until after I had installed NEURON. Is it now hard coded to refer to the previous python?
Yes. You need to rebuild if you installed from sources using --with-nrnpython.

Post Reply