Problem with using neuron module from Python 2.7 in PyCharm

Post Reply
aaronmil
Posts: 35
Joined: Fri Apr 25, 2014 10:54 am

Problem with using neuron module from Python 2.7 in PyCharm

Post by aaronmil »

Hello,

First of all, I am amazed that such a small team is somehow able to heroically troubleshoot the problems of an army of users that have different machines with different software versions. Thank you for your help.

My ultimate goal is to be able to run network models on a cluster, with python code as a base for some high level abstraction, output handling, data analysis, and model optimization, and running NEURON models (hoc code) via the Python neuron module.

My OS is OSX 10.9.2.
My NEURON version is 7.3.
My Python version is 2.7.6.

I followed the installation instructions here:

http://www.neuron.yale.edu/neuron/downl ... ilestd_osx

There were a lot of errors produced during installation, but I appear to now have a functioning NEURON 7.3 that runs fine from the command line. The brief test of open mpi installation succeeded as well.

I would like to be able to use the Community Edition of PyCharm as an IDE for writing and debugging Python code. The strange thing is, I can get Python to execute hoc code in 2/3 places. I am able to execute the following from 1) the command line, 2) the Python 2.7.6 Shell from IDLE, but get an error when executing from 3) the Python Console within PyCharm:

import neuron
h = neuron.hoc.HocObject()
h("create soma")
som = h.soma

the error I receive is:
NEURON: nseg not a USERPROPERTY that can be pointed to
near line 0
create soma
^

Process finished with exit code 139

As far as I can tell, all three of these consoles are referring to the same version of Python and importing the same modules with the same directories extending the sys.path. The reason I would prefer to use PyCharm is the intelligent way that it recognizes method calls and variable references while typing into the console. Any ideas what is going wrong here?
hines
Site Admin
Posts: 1607
Joined: Wed May 18, 2005 3:32 pm

Re: Problem with using neuron module from Python 2.7 in PyCh

Post by hines »

There were a lot of errors produced during installation,
Recently, I quietly updated the standard distribution to avoid these since I was spending a lot of time explaining how to overcome them. Can you make sure that the version you are using has
a banner that mentions 'ansi-1078'? I don't think that will fix the problem but at least we would both be on the same page with the same version. If you tell me the problem still exists then I'll try installing
the community version of PyCharm and see if I can reproduce the problem. I presume it occurs merely with

Code: Select all

from neuron import h
h('create soma')
and that you had set the environment variable
export PYTHONPATH=/Applications/NEURON-7.3/nrn/lib/python
aaronmil
Posts: 35
Joined: Fri Apr 25, 2014 10:54 am

Re: Problem with using neuron module from Python 2.7 in PyCh

Post by aaronmil »

hines wrote: Can you make sure that the version you are using has
a banner that mentions 'ansi-1078'?
When I import I get this banner:

NEURON -- VERSION 7.3 ansi (1085:e3c59dffa8e7) e3c59dffa8e7
Duke, Yale, and the BlueBrain Project -- Copyright 1984-2014

Does that mean it's the wrong version? I should mention that I did incorporate this modification to the installation instructions:
viewtopic.php?f=4&t=3051#p12584
hines wrote: I presume it occurs merely with

Code: Select all

from neuron import h
h('create soma')
and that you had set the environment variable
export PYTHONPATH=/Applications/NEURON-7.3/nrn/lib/python
This is all correct.
hines wrote: If you tell me the problem still exists then I'll try installing
the community version of PyCharm and see if I can reproduce the problem.
That would be greatly appreciated! Thank you.
hines
Site Admin
Posts: 1607
Joined: Wed May 18, 2005 3:32 pm

Re: Problem with using neuron module from Python 2.7 in PyCh

Post by hines »

7.3 ansi (1085:e3c59dffa8e7)
That is fine. You have the latest mercurial repository version. On my machine that eliminated all the clang compiler warnings and errors with no need for extra compiler flags.
I'll try this with PyCharm on my mac air 10.9 and get back to you.
aaronmil
Posts: 35
Joined: Fri Apr 25, 2014 10:54 am

Re: Problem with using neuron module from Python 2.7 in PyCh

Post by aaronmil »

It appears that something more severe might be going on.

If I type
nrngui -python main.hoc

from the command line, everything is fine, i can execute python commands, load .hoc files via h, run simulations, etc.

but if i try to execute from a python shell:

from neuron import h
h('load_file("nrngui.hoc")')

i get a blank white box instead of the actual NEURON GUI

EDIT: found a module that processes the NEURON GUI event loop that seems to fix this issue

http://stuff.mit.edu/afs/athena.mit.edu ... ron/gui.py
hines
Site Admin
Posts: 1607
Joined: Wed May 18, 2005 3:32 pm

Re: Problem with using neuron module from Python 2.7 in PyCh

Post by hines »

launching python means that you do not have the event loop managed by nrniv. On linux and mac we have had
reasonable luck with
from neuron import gui
to start a thread that checks for event every 0.1 s.

I installed PyCharm on my ubuntu 14.04 linux and could not reproduce the problem. I'll try tonight on a mac os x 10.9
hines
Site Admin
Posts: 1607
Joined: Wed May 18, 2005 3:32 pm

Re: Problem with using neuron module from Python 2.7 in PyCh

Post by hines »

NEURON: nseg not a USERPROPERTY that can be pointed to

I was unable to reproduce this problem on mac os x 10.9.2
The PyCharm test I used was

import sys
sys.path.append('/Applications/NEURON-7.3/nrn/lib/python')
from neuron import h
h('create soma')
print h.soma.name()


And the pycharm output is

/System/Library/Frameworks/Python.framework/Versions/2.7/bin/python /Users/michaelhines/PycharmProjects/test/test.py
NEURON -- VERSION 7.3 ansi (1085:e3c59dffa8e7) 2014-04-23
Duke, Yale, and the BlueBrain Project -- Copyright 1984-2014
See http://www.neuron.yale.edu/neuron/credits

soma

Process finished with exit code 0


I do see a temporary Apple bug involving their python and clang when doing a 'make install'. The problem is
clang: error: unknown argument: '-mno-fused-madd' [-Wunused-command-line-argument-hard-error-in-future]
clang: note: this will be a hard error (cannot be downgraded to a warning) in the future

But I worked around it with
export CFLAGS='-Qunused-arguments'
$ export CXXFLAGS='-Qunused-arguments'
make install
Post Reply