Neuron as Python module in Win (again)

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

Re: Neuron as Python module in Win (again)

Post by hines »

I'm unaware that a 64 bit version of pythonxy exists. If ti does, let me know where I can get it.
Presently the only 32 bin mswin version of NEURON that is distributed is a cygwin version.
I'll build a 32 bit mingw version and see if I can get it working with pythonxy. If so, I'll make it available for download.
hines
Site Admin
Posts: 1600
Joined: Wed May 18, 2005 3:32 pm

Re: Neuron as Python module in Win (again)

Post by hines »

Try http://www.neuron.yale.edu/ftp/neuron/v ... -setup.exe
That works for me with
export PYTHONPATH=/c/nrn73w/lib/python
export NEURONHOME=/c/nrn73w
mv /c/nrn73w/bin/hocmodule.dll /c/nrn73w/lib/python/neuron/hoc.pyd

I installed Python(x,y)-2.7.3.1.exe and ran from the installed NEURON's bash icon.
on 'import neuron' I do see a
Unable to load 'mpich2nemesis.dll', error 126
but it seems benign. (I don't remember configureing with --with-paranrn)
patoorio
Posts: 81
Joined: Wed Jan 30, 2008 12:46 pm

Re: Neuron as Python module in Win (again)

Post by patoorio »

It's working!!
The best part is that I can even call spyder from the bash shell and then import neuron. Mods compiled with mknrndll are correctly imported also. I haven't actually run any simulation yet, but be sure that I'll let you know if anything doesnt go as expected.

Thanks a lot.
patoorio
Posts: 81
Joined: Wed Jan 30, 2008 12:46 pm

Re: Neuron as Python module in Win (again)

Post by patoorio »

Hi,

The as_numpy() function is giving an error:

Code: Select all

>>> from neuron import h
Unable to load 'mpich2nemesis.dll', error 126
NEURON -- Release 7.3 (901:c736db45853d) 2013-06-29
Duke, Yale, and the BlueBrain Project -- Copyright 1984-2013
See http://www.neuron.yale.edu/neuron/credits

>>> vec=h.Vector(10)
>>> vec.fill(8)
<hoc.HocObject object at 0x0252D020>
>>> vec.printf()
8       8       8       8       8
8       8       8       8       8

10.0
>>> vec.as_numpy()
NEURON: Vector.as_numpy() error
 near line 0
 objref hoc_obj_[2]
                   ^
        Vector[0].as_numpy()
oc_restore_code tobj_count=1 should be 0
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
RuntimeError: hoc error
>>>
It happens also with the embedded python interpreter.

Best Regards
hines
Site Admin
Posts: 1600
Joined: Wed May 18, 2005 3:32 pm

Re: Neuron as Python module in Win (again)

Post by hines »

I believe the Vector.as_numpy problem is fixed for the mingw versions. Please try
http://www.neuron.yale.edu/ftp/neuron/v ... -setup.exe
Now hoc.pyd is put in the proper place. But you still need NEURONHOME and PYTHONPATH
patoorio
Posts: 81
Joined: Wed Jan 30, 2008 12:46 pm

Re: Neuron as Python module in Win (again)

Post by patoorio »

Thanks!
ioannisv

Re: Neuron as Python module in Win (again)

Post by ioannisv »

patoorio wrote:It's working!!
The best part is that I can even call spyder from the bash shell and then import neuron. Mods compiled with mknrndll are correctly imported also. I haven't actually run any simulation yet, but be sure that I'll let you know if anything doesnt go as expected.

Thanks a lot.
how did you make it work?
I've set the 2 new NEURONHOME and PYTHONPATH variables
I've copied and renamed the file
but I get the exact dll error as you did
hines
Site Admin
Posts: 1600
Joined: Wed May 18, 2005 3:32 pm

Re: Neuron as Python module in Win (again)

Post by hines »

I've copied and renamed the file
What NEURON installer did you use? (The 933 version mentioned above is still there.)
Where did you install NEURON?
What were the statements you used to set the NEURONHOME and PYTHONPATH?
What statement did you use to copy and rename the file? (That should have been unnecessary.)
What python installation did you use?
ioannisv

Re: Neuron as Python module in Win (again)

Post by ioannisv »

I used this neuron installer nrn-7.3.x86_64-w64-mingw32-setup and I installed it on the default installation folder
I have Python(x,y)-2.7.5.0

For environment variable in WIN environment variable editor I used
NEURONHOME C:\nrn73w64
PYTHONPATH C:\nrn73w64\lib\python

when renaming and pasting the files I've done it manual not through the console


edit: I had to copy paste the folder C:\nrn73w64\lib\python in the site-packages folder of Python(x,y) otherwise the module was not visible at all.
hines
Site Admin
Posts: 1600
Joined: Wed May 18, 2005 3:32 pm

Re: Neuron as Python module in Win (again)

Post by hines »

I used this neuron installer nrn-7.3.x86_64-w64-mingw32-setup
The installer that contains the dll bugfix is mentioned a few posts up. Try
http://www.neuron.yale.edu/ftp/neuron/v ... -setup.exe
patoorio
Posts: 81
Joined: Wed Jan 30, 2008 12:46 pm

Re: Neuron as Python module in Win (again)

Post by patoorio »

ioannisv wrote: For environment variable in WIN environment variable editor I used
NEURONHOME C:\nrn73w64
PYTHONPATH C:\nrn73w64\lib\python
You don't have to do it in the Windows environment variables, instead (or in addition to??) you have to do
export NEURONHOME /c/nrn73w64
export PYTHONPATH /c/nrn73w64/lib/python

in the bash command prompt.
It has to be done it only once, apparently it gets stored somewhere.

Regards
ioannisv

Re: Neuron as Python module in Win (again)

Post by ioannisv »

the export command is a UNIX command not working on WIN
I used the equivalent set command

set NEURONHOME=C:\nrn73w64
set PYTHONPATH=C:\nrn73w64\lib\python
patoorio
Posts: 81
Joined: Wed Jan 30, 2008 12:46 pm

Re: Neuron as Python module in Win (again)

Post by patoorio »

ioannisv wrote:the export command is a UNIX command not working on WIN
Exactly!!
As I told you, you have to open a bash command window (A *NIX-like environment that gets installed with neuron, part of MinGW), issue the export commands and run pyhton (or spyder!) from there; then you will be able to import neuron.
It didn't work for me when running python from the DOS command shell nor spyder from the Windows's start button.
jditte
Posts: 5
Joined: Wed Mar 20, 2013 3:40 pm

Enthought Canopy on Windows 64bit

Post by jditte »

Has anybody managed to get Neuron to work in Enthought Canopy (Python IDE; 64bit) on Windows? If so, could you please post some instructions? Thanks!
hines
Site Admin
Posts: 1600
Joined: Wed May 18, 2005 3:32 pm

Re: Neuron as Python module in Win (again)

Post by hines »

installed canopy-1.1.0-full-win-64.msi accepting all default selections.
be sure to setup the canopy environment

installed http://www.neuron.yale.edu/ftp/neuron/v ... -setup.exe

from neuron group start a bash terminal
export NEURONHOME=/c/nrn73w64
export PYTHONPATH=/c/nrn73w64/lib/python

at this point:
python
import neuron
is supposed to work. However I got
import neuron.hoc
ImportError: DLL load failed: The specified procedure could not be found.
But, for some unknown reason if I copy all of NEURON's dlls to the neuron module
cp /c/nrn73w64/bin64/*.dll /c/nrn73w64/lib/python/neuron
it starts to work. (I don't know which subset is actually important or why they have to be in the neuron module location)
Note that launching python does not allow classic NEURON graphics from InterViews. Also, when I launch nrniv -python, I get the perplexing
ImportError: No module named site
problem and I haven't figured out yet how to fix that.
Post Reply