Turn off print messages in NEURON

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

Moderator: hines

Post Reply
rgerkin
Posts: 10
Joined: Fri Oct 06, 2017 11:38 am

Turn off print messages in NEURON

Post by rgerkin »

When using NEURON from Python, I get lots of printed messages that I don't really want to see. If they originate from the NEURON python module, I am able to intercept them and redirect from stdout to another buffer that I can check later (if needed). But the ones coming from the C libraries I am having trouble catching, and they are cluttering up all of my stdout. Is there a way to configure neuron (maybe from an environment variable) to turn off all stdout originating from C?
hines
Site Admin
Posts: 1682
Joined: Wed May 18, 2005 3:32 pm

Re: Turn off print messages in NEURON

Post by hines »

With the most recent master from github, all (or at least most) of printf in c is redirected to the python stdout (if python is the launched program).
This was done so that all output with jupyter notebooks goes to the notebook.
Note that the statement that actually does the printing is line 687 of nrn/share/lib/python/neuron/__init__.py

Code: Select all

   sys.stdout.write(s.decode())
Is this the stdout that you redirected?
rgerkin
Posts: 10
Joined: Fri Oct 06, 2017 11:38 am

Re: Turn off print messages in NEURON

Post by rgerkin »

I was using NEURON 7.5 so I don't think I had this functionality yet. It seems likely that I will be able to redirect stdout as needed entirely with Python calls in NEURON 7.6, since this commit https://github.com/neuronsimulator/nrn/ ... 2f80226f62, which contains the code you described, is tagged with 7.6.0. Thank you!
Post Reply