ImportError: No module named site

Post Reply
PeterG
Posts: 4
Joined: Thu Jan 26, 2017 10:10 am

ImportError: No module named site

Post by PeterG »

After install Neuron (trough a nrn deb pacakge) I started nrniv and get the following message:

Warning: no DISPLAY environment variable.
--No graphics will be displayed.
NEURON -- Release 7.4 (1370:16a7055d4a86) 2015-11-09
Duke, Yale, and the BlueBrain Project -- Copyright 1984-2015
See http://www.neuron.yale.edu/neuron/credits

ImportError: No module named site
Py_Initialize exited. PYTHONHOME probably needs to be set correctly.
Our automatic guess based on the Python shared library location:
export PYTHONHOME=/usr/lib
did not work.
It will help to examine the output of:
nrnpyenv.sh
and set the indicated environment variables, or avoid python by adding
nopython: on
to /usr/local/nrn/share/nrn/lib/nrn.defaults (or .nrn.defaults in your $HOME directory)

I did run nrnpyenv.sh and get the following message:
# items in sys.path = 11
# beginning with sys.prefix = 10
# site-3 same as sys.prefix
# in neither location ['.']
# sys.prefix = /usr
# site-3 = /usr
export PYTHONHOME="/usr"
export LD_LIBRARY_PATH="/usr/lib:$LD_LIBRARY_PATH"

In /etc/profile.d I add in a file export PYTHONHOME to the right location? but the error message appears again.
Als disable nopython: on in /usr/local/nrn/share/nrn/lib/nrn.defaults doesn't work.
I do use BIO-Linux with Ubuntu 16.04 LTS

How can I solved this problem?

Thanks in advance
Peter
ted
Site Admin
Posts: 6286
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: ImportError: No module named site

Post by ted »

After install Neuron (trough a nrn deb pacakge)
0. Has NEURON ever been successfully installed on this particular PC before?
1. Did you get the "nrn deb package" directly from NEURON's web site www.neuron.yale.edu, or did it come from somewhere else?
2. Do you really want no graphics?
PeterG
Posts: 4
Joined: Thu Jan 26, 2017 10:10 am

Re: ImportError: No module named site

Post by PeterG »

Answers:
0. Yes, is installed and nrniv and nrngui works, but get always the PYTHONHOME error.
1. I've download nrn-7.4.x86_64.deb directly from the neuron website.
2. Depents, I 'll it use with mpi.
hines
Site Admin
Posts: 1682
Joined: Wed May 18, 2005 3:32 pm

Re: ImportError: No module named site

Post by hines »

Does
nrniv -nopython
work? And are you sure your version of nrniv comes from /usr/local/bin. ie. what is the result of
which nrniv

Without the -nopython arg, does the line in /usr/local/nrn/share/nrn/lib/nrn.defaults take effect when it is changed to
*nopython: on
(ie with the first character '*')

Now, with regard to eliminating the 'site' problem while still being able to embed Python, be sure
to remove the "*nopython: on" line in nrn.defaults
When you start a terminal window, is there an environment variable for PYTHONHOME and what is its value.

Does the following work?
export PYTHONPATH=/usr/local/nrn/lib/python
python
import neuron
PeterG
Posts: 4
Joined: Thu Jan 26, 2017 10:10 am

Re: ImportError: No module named site

Post by PeterG »

Your advice to add export PYTHONPATH=/usr/local/nrn/lib/python solved the problem with nrniv

nrniv []
NEURON -- Release 7.4 (1370:16a7055d4a86) 2015-11-09
Duke, Yale, and the BlueBrain Project -- Copyright 1984-2015
See http://www.neuron.yale.edu/neuron/credits

oc>

I do not have a environment variable for PYTHONHOME

python version =
Python 2.7.12 (default, Nov 19 2016, 06:48:10)
[GCC 5.4.0 20160609] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>>

which nrniv = /usr/local/bin/nrniv []

import neuron = do nothing (cursor blinking)

Now I tried to run mpiexec -n 4 nrniv -mpi initbatpar.hoc , but I get the error message (see below)
What is the right path of export PYTHONHOME ?

mpiexec -n 4 nrniv -mpi initbatpar.hoc []
numprocs=1
NEURON -- Release 7.4 (1370:16a7055d4a86) 2015-11-09
Duke, Yale, and the BlueBrain Project -- Copyright 1984-2015
See http://www.neuron.yale.edu/neuron/credits

numprocs=1
NEURON -- Release 7.4 (1370:16a7055d4a86) 2015-11-09
Duke, Yale, and the BlueBrain Project -- Copyright 1984-2015
See http://www.neuron.yale.edu/neuron/credits

ImportError: No module named site
Py_Initialize exited. PYTHONHOME probably needs to be set correctly.
Our automatic guess based on the Python shared library location:
export PYTHONHOME=/usr/lib
did not work.
It will help to examine the output of:
nrnpyenv.sh
and set the indicated environment variables, or avoid python by adding
nopython: on
to /usr/local/nrn/share/nrn/lib/nrn.defaults (or .nrn.defaults in your $HOME directory)
-------------------------------------------------------
Primary job terminated normally, but 1 process returned
a non-zero exit code.. Per user-direction, the job has been aborted.
-------------------------------------------------------
--------------------------------------------------------------------------
mpiexec detected that one or more processes exited with non-zero status, thus causing
the job to be terminated. The first process to do so was:

Process name: [[17526,1],0]
Exit code: 1
hines
Site Admin
Posts: 1682
Joined: Wed May 18, 2005 3:32 pm

Re: ImportError: No module named site

Post by hines »

Your advice to add export PYTHONPATH=/usr/local/nrn/lib/python solved the problem with nrniv
That is unexpected. That is only to tell where Python can find the neuron module when you launch python (instead of nrniv)
The idea about PYTHONHOME is to tell nrniv (when you launch nrniv) where it can find the proper python environment and hence
resolve the location of 'site'. By the way, the exact location of the site module can be obtained by
python
import site
print site.__file__
I do not have a environment variable for PYTHONHOME
That is another surprise. I thought in your earlier email you mentioned.
In /etc/profile.d I add in a file export PYTHONHOME to the right location?
So whether the value is right or wrong, the environement variable should at least exist. Perhaps I'm mistaken in thinking that /etc/profile.d is read when you start a terminal or perhas the standard shell (as opposed to
bash) syntax is as two lines
PYTHONHOME=/usr
export PYTHONHOME
Anyway, you might try putting it into your $HOME/.bashrc file as
export PYTHONHOME=/usr
which should take effect on all subsequent lauches of a terminal window.
mpiexec -n 4 nrniv -mpi initbatpar.hoc
See if this works with
mpiexec -n 4 nrniv -mpi -nopython initbatbar.hoc
The problem is not just 'site' however, but the fact that 4 uncommunicating nrniv processes were launched each thinking it is by itself. This is what is expected if the '-mpi' arg is missing.
I just installed http://www.neuron.yale.edu/ftp/neuron/v ... x86_64.deb
and see that it was built using mpich and not openmpi. For that deb file to work on my machine I need:
export PATH=/usr/local/bin:$HOME/soft/mpich/bin:$PATH
export PYTHONHOME=/usr
export LD_LIBRARY_PATH=$HOME/soft/mpich/lib
$ mpiexec -n 4 nrniv -mpi -c 'quit()'
numprocs=4
NEURON -- Release 7.4 (1370:16a7055d4a86) 2015-11-09
Duke, Yale, and the BlueBrain Project -- Copyright 1984-2015
See http://www.neuron.yale.edu/neuron/credits
PeterG
Posts: 4
Joined: Thu Jan 26, 2017 10:10 am

Re: ImportError: No module named site

Post by PeterG »

The problem was neuron doen't found PYTHONHOME=/usr
I've add PYTHONHOME=/usr in /etc/environment .

Now Neuron works and it's useable for everyone.
Thanks
Post Reply