Page 2 of 2

Re: no module named hoc

Posted: Sat May 10, 2008 12:59 pm
by eacheon
in neuron/__init__.py, if

Code: Select all

import hoc
is changed to

Code: Select all

from neuron import hoc
Then the problem goes away.
emuller wrote:
arb wrote: after make install I switched to the src/nrnpython dir and
typed python setup.py install in super user mode:
...

Python 2.5.1 (r251:54863, May 2 2007, 16:56:35)
[GCC 4.1.2 (Ubuntu 4.1.2-0ubuntu4)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import neuron
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "neuron/__init__.py", line 9, in <module>
import hoc
ImportError: No module named hoc

what is still wrong?
armin
This occurs if the current directory is src/nrnpython

Move up one directory, try again and it should work.

I will add a warning message that informs the user of this error case, and submit it to Michael.

Eilif.

python import neuron problem

Posted: Tue Feb 01, 2011 5:46 pm
by wwlytton
I still seem to be having this problem (or a very similar one?) 2 years on??

>>> import sys
>>> sys.path.append('/usr/site/nrniv/nrn/share/lib/python')
>>> import neuron
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/site/nrniv/nrn/share/lib/python/neuron/__init__.py", line 81, in <module>
import neuron.hoc
ImportError: No module named hoc
>>> import hoc
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named hoc

Re: Compling Problem

Posted: Fri Feb 04, 2011 5:29 pm
by hines
If you launch

nrniv -python
import neuron

is there an error? Or does this only occur when you launch python. Assuming the latter,
it is not surprising that the the path you added is insufficient since that is not where
the hoc.so file is. What command did you use after make install when you cd'd to the
src/nrnpython directory and executed
.....python setup.py install ......

Re: Compling Problem

Posted: Fri Feb 04, 2011 7:27 pm
by wwlytton
> .....python setup.py install ......

ok, this is the problem; this is the step I was trying to side-step; sorry I should have made that clear but had mistakenly been thinking that this was an optional rather than an obligatory step

this step requires writing to python system directories rather than to directories that were created during the NEURON install
so need root permissions (or else need to install my own python):
error: could not create '/usr/local/lib/python2.6/dist-packages/neuron': Permission denied

Re: Compling Problem

Posted: Fri Feb 04, 2011 7:32 pm
by hines
this step requires writing to python system directories
Not really. I use
python setup.py install --home=$HOME
which installs in $HOME/lib/python.
I then use the environment variable
export PYTHONPATH=$HOME/lib/python

This is mentioned at
http://www.neuron.yale.edu/neuron/stati ... stallation

Re: Compling Problem

Posted: Sat Dec 22, 2018 12:37 pm
by javierzsm
Hi,
I'm installing version 7.6.2 and want to import neuron from python.

Everything seems to be ok during the compilation but then, when I run python setup.py install --home=$HOME
this is what I get:

ME
File "setup.py", line 80
= [ epre+libdirs[0],epre+libdirs[1] ],
^
SyntaxError: invalid syntax

Any help?

Re: Compling Problem

Posted: Sat Dec 22, 2018 1:10 pm
by hines
Looks like I have a bad substitution line in nrn/src/nrnpython/setup.py.in which reads

Code: Select all

@setup_extra_link_args@ = [ epre+libdirs[0],epre+libdirs[1] ],
and should get replaced in setup.py with either

Code: Select all

      extra_link_args = [ epre+libdirs[0],epre+libdirs[1] ],
or

Code: Select all

      #extra_link_args = [ epre+libdirs[0],epre+libdirs[1] ],
But apparently the '#' is not being properly escaped.
In your build folder, what is the result of
grep 'extra_link_args' config.status