Compling Problem

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

Moderator: hines

eacheon
Posts: 97
Joined: Wed Jan 18, 2006 2:20 pm

Re: no module named hoc

Post by eacheon » Sat May 10, 2008 12:59 pm

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.

wwlytton
Posts: 65
Joined: Wed May 18, 2005 10:37 pm
Contact:

python import neuron problem

Post by wwlytton » Tue Feb 01, 2011 5:46 pm

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

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

Re: Compling Problem

Post by hines » Fri Feb 04, 2011 5:29 pm

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 ......

wwlytton
Posts: 65
Joined: Wed May 18, 2005 10:37 pm
Contact:

Re: Compling Problem

Post by wwlytton » Fri Feb 04, 2011 7:27 pm

> .....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

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

Re: Compling Problem

Post by hines » Fri Feb 04, 2011 7:32 pm

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

javierzsm
Posts: 1
Joined: Tue Jul 21, 2015 12:19 pm

Re: Compling Problem

Post by javierzsm » Sat Dec 22, 2018 12:37 pm

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?

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

Re: Compling Problem

Post by hines » Sat Dec 22, 2018 1:10 pm

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

Post Reply