# One hot gym prediction or anomaly - plotting error

**URL:** https://discourse.numenta.org/t/one-hot-gym-prediction-or-anomaly-plotting-error/5761
**Category:** NuPIC
**Created:** [April 6, 2019, 12:36pm UTC](https://discourse.numenta.org/t/one-hot-gym-prediction-or-anomaly-plotting-error/5761 "2019-04-06T12:36:48Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Razvan\_Flavius\_Panda](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.numenta.org/razvan_flavius_panda/32/3747_2.png) [@Razvan\_Flavius\_Panda](https://discourse.numenta.org/u/Razvan_Flavius_Panda)
#### Post date: [April 6, 2019, 12:36pm UTC](https://discourse.numenta.org/t/one-hot-gym-prediction-or-anomaly-plotting-error/5761/1 "2019-04-06T12:36:48Z")

</div>

Getting the following error when running `python run.py --plot`:

```
Traceback (most recent call last):
  File "run.py", line 151, in <module>
    runModel(GYM_NAME, plot=plot)
  File "run.py", line 141, in runModel
    runIoThroughNupic(inputData, model, gymName, plot)
  File "run.py", line 98, in runIoThroughNupic
    output = nupic_output.NuPICPlotOutput([gymName])
  File "/home/neo/Projects/nupic/examples/opf/clients/hotgym/prediction/one_gym/nupic_output.py", line 116, in __init__
    plt.ion()
NameError: global name 'plt' is not defined
```

---

<div class="post-metadata">

### Author: ![rhyolight](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.numenta.org/rhyolight/32/3922_2.png) [@rhyolight](https://discourse.numenta.org/u/rhyolight)
#### Post date: [April 6, 2019, 3:45pm UTC](https://discourse.numenta.org/t/one-hot-gym-prediction-or-anomaly-plotting-error/5761/2 "2019-04-06T15:45:03Z")

</div>

This is because `matplotlib` is unreliable in many environments (yours!).

> <https://github.com/numenta/nupic/blob/master/examples/opf/clients/hotgym/prediction/one_gym/nupic_output.py#L29-L37>

You need to figure how to get it installed on your OS in python properly.

---

<div class="post-metadata">

### Author: ![Razvan\_Flavius\_Panda](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.numenta.org/razvan_flavius_panda/32/3747_2.png) [@Razvan\_Flavius\_Panda](https://discourse.numenta.org/u/Razvan_Flavius_Panda)
#### Post date: [April 6, 2019, 9:13pm UTC](https://discourse.numenta.org/t/one-hot-gym-prediction-or-anomaly-plotting-error/5761/3 "2019-04-06T21:13:26Z")

</div>

Ah, getting closer to the issue:

```
>>> import matplotlib.pyplot
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/neo/.local/lib/python2.7/site-packages/matplotlib/pyplot.py", line 115, in <module>
    _backend_mod, new_figure_manager, draw_if_interactive, _show = pylab_setup()
  File "/home/neo/.local/lib/python2.7/site-packages/matplotlib/backends/ __init__.py", line 63, in pylab_setup
    [backend_name], 0)
  File "/home/neo/.local/lib/python2.7/site-packages/matplotlib/backends/backend_tkagg.py", line 4, in <module>
    from . import tkagg # Paint image to Tk photo blitter extension.
  File "/home/neo/.local/lib/python2.7/site-packages/matplotlib/backends/tkagg.py", line 5, in <module>
    from six.moves import tkinter as Tk
  File "/home/neo/.local/lib/python2.7/site-packages/six.py", line 203, in load_module
    mod = mod._resolve()
  File "/home/neo/.local/lib/python2.7/site-packages/six.py", line 115, in _resolve
    return _import_module(self.mod)
  File "/home/neo/.local/lib/python2.7/site-packages/six.py", line 82, in _import_module
    __import__ (name)
  File "/usr/lib/python2.7/lib-tk/Tkinter.py", line 42, in <module>
    raise ImportError, str(msg) + ', please install the python-tk package'
ImportError: No module named _tkinter, please install the python-tk package

```

Run:

```
sudo apt-get install python-tk

```

And now it is working.  
Thank you very much for the clue!

---

<div class="post-metadata">

### Author: ![helena\_Thielen](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.numenta.org/helena_thielen/32/4343_2.png) [@helena\_Thielen](https://discourse.numenta.org/u/helena_Thielen)
#### Post date: [June 27, 2019, 11:40am UTC](https://discourse.numenta.org/t/one-hot-gym-prediction-or-anomaly-plotting-error/5761/4 "2019-06-27T11:40:44Z")

</div>

Hey 😊

I have an issue if the plot as well.  
I could import everything in the files, so also this part

```auto
try:
  import matplotlib
  matplotlib.use('TKAgg')
  import matplotlib.pyplot as plt
  import matplotlib.gridspec as gridspec
  from matplotlib.dates import date2num
except ImportError:
  pass

```

by using as second line the following:

```auto
matplotlib.use('TKAgg',warn=False, force=True)

```

I know this is not really a specific HTM Problem. But I searched on the Internet for a looooooong time, without finding a solution. So sorry to annoy here with that, but I hope that maybe someone had the same problem and can help me with that.

The thing is, that I got a figure in a new window, but it does not show anything. Just at the very end, I can see some results (just the very last days) .

I would really appreciate any help 🤗🙂  
thanks to everyone in advance. 🥳🥳🥳
