Could not display figures while running from terminal in Jupyter lab

133 views
Skip to first unread message

Clea Smith

unread,
Jul 1, 2021, 12:11:46 PM7/1/21
to SpiNNaker Users Group
Hi spinnaker group,

I was trying to run my simulation through the Jupyter lab terminal, but the I was complained about the issue below while it was running my script.

2021-07-01 16:05:02 ERROR: Shutdown on exception
Traceback (most recent call last):
  File "IF_cond_exp_adap_thres_example.py", line 64, in <module>
    Panel(test_pop_v.segments[0].filter(name='v')[0],xticks=True,yticks=True, ylabel='Voltage', xlim=(0,run_time))
  File "/home/spinnaker/sPyNNakerGit/lib/python3.6/site-packages/pyNN/utility/plotting.py", line 193, in __init__
    self.fig = plt.figure(1, figsize=(width, height))
  File "/home/spinnaker/sPyNNakerGit/lib/python3.6/site-packages/matplotlib/pyplot.py", line 546, in figure
    **kwargs)
  File "/home/spinnaker/sPyNNakerGit/lib/python3.6/site-packages/matplotlib/backend_bases.py", line 3358, in new_figure_manager
    return cls.new_figure_manager_given_figure(num, fig)
  File "/home/spinnaker/sPyNNakerGit/lib/python3.6/site-packages/matplotlib/backends/_backend_tk.py", line 888, in new_figure_manager_given_figure
    window = tk.Tk(className="matplotlib")
  File "/usr/lib/python3.6/tkinter/__init__.py", line 2023, in __init__
    self.tk = _tkinter.create(screenName, baseName, className, interactive, wantobjects, useTk, sync, use)
_tkinter.TclError: couldn't connect to display ":0"

These log messages where generated at level WARNING or above
/home/spinnaker/sPyNNakerGit/sPyNNaker8NewModelTemplate/examples/reports has 5 old reports that have not been closed
Shutdown on exception

There were data saved in the middle of the simulation, and it indicated successful running. Can I be advised how I could address this? ( I was running the script after using "source bin/activate" )

Many Thanks
Clea

Andrew Gait

unread,
Jul 1, 2021, 12:49:19 PM7/1/21
to SpiNNaker Users Group
Hi Clea,

There's no way of displaying a figure from a JupyterLab terminal (since it doesn't know what "display" to send the figure to), or at least I don't know of one (someone else may contradict me here... ?).  In order to display a figure I believe you have to do it by running the script from a notebook rather than running the script in the terminal window.

Andy

----------------------------------------------------
Dr. Andrew Gait,
Research Software Engineer,
APT Group,
Department of Computer Science,
The University of Manchester,
Oxford Road, Manchester M13 9PL

email: andre...@manchester.ac.uk
web: http://personalpages.manchester.ac.uk/staff/Andrew.Gait/

From: spinnak...@googlegroups.com <spinnak...@googlegroups.com> on behalf of Clea Smith <clea...@gmail.com>
Sent: 01 July 2021 17:11
To: SpiNNaker Users Group <spinnak...@googlegroups.com>
Subject: [SpiNNaker Mailing List] Could not display figures while running from terminal in Jupyter lab
 
--
You received this message because you are subscribed to the Google Groups "SpiNNaker Users Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to spinnakeruser...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/spinnakerusers/6c6da2ba-9466-44da-9208-7f5b4369861an%40googlegroups.com.

Andrew Rowley

unread,
Jul 2, 2021, 3:32:14 AM7/2/21
to SpiNNaker Users Group

Hi,

 

This is correct; the best, and possibly only, way to run a python script on Jupyter if you want to display graphics is to run it in a Jupyter notebook.

 

Andrew :)

Reply all
Reply to author
Forward
0 new messages