Page 1 of 1

What sets the sys.path for nrniv -python?

Posted: Thu Dec 11, 2014 4:44 pm
by aaronmil
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

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

Posted: Thu Dec 11, 2014 5:13 pm
by aaronmil
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.

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

Posted: Fri Dec 12, 2014 6:10 pm
by ted
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?

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

Posted: Sat Dec 13, 2014 10:44 am
by aaronmil
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?

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

Posted: Sat Dec 13, 2014 6:19 pm
by ted
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.

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

Posted: Sun Dec 14, 2014 12:56 am
by hines
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.