# "Output messages" window stop working after running a macro that uses Matplotlib (MacOS)

**URL:** https://discourse.paraview.org/t/output-messages-window-stop-working-after-running-a-macro-that-uses-matplotlib-macos/8837
**Category:** ParaView Support
**Tags:** python
**Created:** [January 25, 2022, 12:32am UTC](https://discourse.paraview.org/t/output-messages-window-stop-working-after-running-a-macro-that-uses-matplotlib-macos/8837 "2022-01-25T00:32:39Z")
**Posts on this page:** 20
**Page:** 1

<div class="post-metadata">

### Author: ![Matheus\_Viana](https://discourse.paraview.org/user_avatar/discourse.paraview.org/matheus_viana/32/8428_2.png) [@Matheus\_Viana](https://discourse.paraview.org/u/Matheus_Viana)
#### Post date: [January 25, 2022, 12:32am UTC](https://discourse.paraview.org/t/output-messages-window-stop-working-after-running-a-macro-that-uses-matplotlib-macos/8837/1 "2022-01-25T00:32:39Z")

</div>

Hi. I have a Python macro that outputs some information about the data being visualized in the “Output Messages”. window. This macro also has a function that makes a plot using Matplotlib and saves it as a PNG file. However, after this function runs, the output messages windows does not display anything else. It is almost like if the default IO had been redirected to something else. Does anyone know a possible solution to get the output messages windows back to work? Here is a short example that illustrates the problem:

```auto
import matplotlib.pyplot as plt
print("Starting to make the plot.")
#fig, ax = plt.subplots(); plt.close("all")
print("Plot saved.")

```

Nothing is shown in output messages window if I uncomment the line.

---

<div class="post-metadata">

### Author: ![pavel](https://discourse.paraview.org/user_avatar/discourse.paraview.org/pavel/32/8287_2.png) [@pavel](https://discourse.paraview.org/u/pavel)
#### Post date: [January 25, 2022, 5:58am UTC](https://discourse.paraview.org/t/output-messages-window-stop-working-after-running-a-macro-that-uses-matplotlib-macos/8837/2 "2022-01-25T05:58:38Z")

</div>

Hi Matheus,

I tried to use matplotlib.pyplot inside a macro for ParaView. The macro:

> print(‘Start…’)  
> import matplotlib.pyplot as plt  
> print(‘pyplot has been imported’)  
> x = [1,2,3]  
> y = [5,3,7]  
> plt.plot(x, y)  
> print(‘pyplot.plot has been called’)  
> plt.savefig(r’C:\P\testgfig.png’)  
> print(‘…figure has been saved.’)

After running it, ‘output messages’ window shows all the printed lines:

![output_messages_win](https://discourse.paraview.org/uploads/default/original/2X/7/7602c3ffd7b4138ba7b988e2bc4a440feaa88172.png)

and I have a plot in png file:

 ![test_plot](https://discourse.paraview.org/uploads/default/original/2X/d/ddc17b619e20186fa7dec36a66794686a004a654.png)

In case of using subplots, it also works:

> print(‘Start…’)  
> import matplotlib.pyplot as plt  
> print(‘pyplot has been imported’)  
> x = [1,2,3]  
> y = [5,3,7]  
> fig, ax = plt.subplots(nrows=1, ncols=1)  
> ax.plot(x, y)  
> print(‘pyplot.plot has been called’)  
> fig.savefig(r’C:\P\testgfig2.png’)  
> print(‘figure has been saved’)  
> plt.close(fig)  
> print(‘…done.’)

![output_messages_win_2](https://discourse.paraview.org/uploads/default/original/2X/7/7f88680e9bc267257421836ae253856ec5b3fff5.png)

And I can see the same picture saved on a disk.  
With ‘plt.close(“all”)’, the output is the same.

Hope this is a solution for you.

Best Regards,  
Pavel

---

<div class="post-metadata">

### Author: ![Matheus\_Viana](https://discourse.paraview.org/user_avatar/discourse.paraview.org/matheus_viana/32/8428_2.png) [@Matheus\_Viana](https://discourse.paraview.org/u/Matheus_Viana)
#### Post date: [January 25, 2022, 6:22am UTC](https://discourse.paraview.org/t/output-messages-window-stop-working-after-running-a-macro-that-uses-matplotlib-macos/8837/3 "2022-01-25T06:22:30Z")

</div>

Hi Pavel. Thank you for looking at this.

I used plt.close(“all”) just to make sure all plots are closed when I created them inside a loop. It is not necessary in this example and I still see the problem when I get rid of it.

I tried the version of code you posted first and I still have problem. Nothing is shown and no file is saved. I am running Paraview 5.10.0-RC2 on Mac OS 11.6. I see you are running Windows. Do you think the OS is the source of problem here?

---

<div class="post-metadata">

### Author: ![pavel](https://discourse.paraview.org/user_avatar/discourse.paraview.org/pavel/32/8287_2.png) [@pavel](https://discourse.paraview.org/u/pavel)
#### Post date: [January 25, 2022, 6:34am UTC](https://discourse.paraview.org/t/output-messages-window-stop-working-after-running-a-macro-that-uses-matplotlib-macos/8837/4 "2022-01-25T06:34:13Z")

</div>

I am using ParaView 5.9.1 (yes, on Windows).  
I tried to run your script exactly:

> import matplotlib.pyplot as plt  
> print(“Starting to make the plot.”)  
> fig, ax = plt.subplots(); plt.close(“all”)  
> print(“Plot saved.”)

and it works:

![output_messages_win_4](https://discourse.paraview.org/uploads/default/original/2X/a/af2c98ff7bb270fff522244803cf12b4c3055ea3.png)

I’m not sure that the problem is in MacOS. Could you please check the path to the png file which you specify for savefig()? Or provide the full script?

Best Regards,  
Pavel

---

<div class="post-metadata">

### Author: ![Matheus\_Viana](https://discourse.paraview.org/user_avatar/discourse.paraview.org/matheus_viana/32/8428_2.png) [@Matheus\_Viana](https://discourse.paraview.org/u/Matheus_Viana)
#### Post date: [January 25, 2022, 6:37am UTC](https://discourse.paraview.org/t/output-messages-window-stop-working-after-running-a-macro-that-uses-matplotlib-macos/8837/5 "2022-01-25T06:37:50Z")

</div>

This is the code I am running now:

```auto
print("Start…")
import matplotlib.pyplot as plt
print("pyplot has been imported")
x = [1,2,3]
y = [5,3,7]
plt.plot(x, y)
print("pyplot.plot has been called")
plt.savefig("/Users/viana/Desktop/viz/testgfig.png")
print("…figure has been saved.")

```

Nothing is shown and no file has been saved. Yes, the path is correct.

---

<div class="post-metadata">

### Author: ![pavel](https://discourse.paraview.org/user_avatar/discourse.paraview.org/pavel/32/8287_2.png) [@pavel](https://discourse.paraview.org/u/pavel)
#### Post date: [January 25, 2022, 6:42am UTC](https://discourse.paraview.org/t/output-messages-window-stop-working-after-running-a-macro-that-uses-matplotlib-macos/8837/6 "2022-01-25T06:42:54Z")

</div>

Looks good. I’m sorry for stupid question: did you ‘Import new macro…’ first, and then click on the name of the loaded macro in the list below on the same menu panel?

---

<div class="post-metadata">

### Author: ![Matheus\_Viana](https://discourse.paraview.org/user_avatar/discourse.paraview.org/matheus_viana/32/8428_2.png) [@Matheus\_Viana](https://discourse.paraview.org/u/Matheus_Viana)
#### Post date: [January 25, 2022, 6:47am UTC](https://discourse.paraview.org/t/output-messages-window-stop-working-after-running-a-macro-that-uses-matplotlib-macos/8837/7 "2022-01-25T06:47:33Z")

</div>

Yes, this is what I do. If I try a second time, then Paraview crashes on me. However, this second time the file was saved. Nothing is shown in “Output Messages” window both times.

---

<div class="post-metadata">

### Author: ![pavel](https://discourse.paraview.org/user_avatar/discourse.paraview.org/pavel/32/8287_2.png) [@pavel](https://discourse.paraview.org/u/pavel)
#### Post date: [January 25, 2022, 6:51am UTC](https://discourse.paraview.org/t/output-messages-window-stop-working-after-running-a-macro-that-uses-matplotlib-macos/8837/8 "2022-01-25T06:51:50Z")

</div>

Thanks. And if you do not use matplotlib.pyplot at all, can you see some output in “Output Messages” window?

---

<div class="post-metadata">

### Author: ![Matheus\_Viana](https://discourse.paraview.org/user_avatar/discourse.paraview.org/matheus_viana/32/8428_2.png) [@Matheus\_Viana](https://discourse.paraview.org/u/Matheus_Viana)
#### Post date: [January 25, 2022, 6:52am UTC](https://discourse.paraview.org/t/output-messages-window-stop-working-after-running-a-macro-that-uses-matplotlib-macos/8837/9 "2022-01-25T06:52:43Z")

</div>

Yes. Everything fine if I don’t use Matplotlib.

---

<div class="post-metadata">

### Author: ![pavel](https://discourse.paraview.org/user_avatar/discourse.paraview.org/pavel/32/8287_2.png) [@pavel](https://discourse.paraview.org/u/pavel)
#### Post date: [January 25, 2022, 6:55am UTC](https://discourse.paraview.org/t/output-messages-window-stop-working-after-running-a-macro-that-uses-matplotlib-macos/8837/10 "2022-01-25T06:55:22Z")

</div>

Ok. We can check matplotlib version, but I’m not sure it will help. I think we need help from someone from Kitware.

---

<div class="post-metadata">

### Author: ![Matheus\_Viana](https://discourse.paraview.org/user_avatar/discourse.paraview.org/matheus_viana/32/8428_2.png) [@Matheus\_Viana](https://discourse.paraview.org/u/Matheus_Viana)
#### Post date: [January 25, 2022, 6:58am UTC](https://discourse.paraview.org/t/output-messages-window-stop-working-after-running-a-macro-that-uses-matplotlib-macos/8837/11 "2022-01-25T06:58:21Z")

</div>

This is what I have:

```auto
>>> matplotlib. __version__'3.2.1'

```

Let me test another version of Paraview.

---

<div class="post-metadata">

### Author: ![Matheus\_Viana](https://discourse.paraview.org/user_avatar/discourse.paraview.org/matheus_viana/32/8428_2.png) [@Matheus\_Viana](https://discourse.paraview.org/u/Matheus_Viana)
#### Post date: [January 25, 2022, 7:14am UTC](https://discourse.paraview.org/t/output-messages-window-stop-working-after-running-a-macro-that-uses-matplotlib-macos/8837/12 "2022-01-25T07:14:59Z")

</div>

Everything works fine on Paraview 5.9.1. Maybe you could try to run Paraview 5.10 and see if you notice the same problem on Windows?

---

<div class="post-metadata">

### Author: ![pavel](https://discourse.paraview.org/user_avatar/discourse.paraview.org/pavel/32/8287_2.png) [@pavel](https://discourse.paraview.org/u/pavel)
#### Post date: [January 25, 2022, 8:22am UTC](https://discourse.paraview.org/t/output-messages-window-stop-working-after-running-a-macro-that-uses-matplotlib-macos/8837/13 "2022-01-25T08:22:23Z")

</div>

Yes, I can try the same script for PV 5.10.

---

<div class="post-metadata">

### Author: ![pavel](https://discourse.paraview.org/user_avatar/discourse.paraview.org/pavel/32/8287_2.png) [@pavel](https://discourse.paraview.org/u/pavel)
#### Post date: [January 25, 2022, 11:58am UTC](https://discourse.paraview.org/t/output-messages-window-stop-working-after-running-a-macro-that-uses-matplotlib-macos/8837/14 "2022-01-25T11:58:00Z")

</div>

I checked. All the previous scripts work fine in PV 5.10.0 (on Windows). Previously you mentioned Paraview 5.10.0- **RC2**. Maybe downloading and using stable version 5.10.0 is the solution for your issue?

---

<div class="post-metadata">

### Author: ![Matheus\_Viana](https://discourse.paraview.org/user_avatar/discourse.paraview.org/matheus_viana/32/8428_2.png) [@Matheus\_Viana](https://discourse.paraview.org/u/Matheus_Viana)
#### Post date: [January 25, 2022, 4:57pm UTC](https://discourse.paraview.org/t/output-messages-window-stop-working-after-running-a-macro-that-uses-matplotlib-macos/8837/15 "2022-01-25T16:57:07Z")

</div>

Good point. I will try that at some point today and post the result here.  
Best,  
Matheus

---

<div class="post-metadata">

### Author: ![Matheus\_Viana](https://discourse.paraview.org/user_avatar/discourse.paraview.org/matheus_viana/32/8428_2.png) [@Matheus\_Viana](https://discourse.paraview.org/u/Matheus_Viana)
#### Post date: [January 25, 2022, 6:27pm UTC](https://discourse.paraview.org/t/output-messages-window-stop-working-after-running-a-macro-that-uses-matplotlib-macos/8837/16 "2022-01-25T18:27:23Z")

</div>

Same problem using stable PV 5.10.0. So annoying sigh… The rendering looks so much better for me in PV 5.10 but now bc of this bug I am stuck with PV 5.9. I hope someone else have other ideas…

---

<div class="post-metadata">

### Author: ![pavel](https://discourse.paraview.org/user_avatar/discourse.paraview.org/pavel/32/8287_2.png) [@pavel](https://discourse.paraview.org/u/pavel)
#### Post date: [January 26, 2022, 2:34pm UTC](https://discourse.paraview.org/t/output-messages-window-stop-working-after-running-a-macro-that-uses-matplotlib-macos/8837/17 "2022-01-26T14:34:51Z")

</div>

By the way, I have an issue with importing matplotlib using macro or Python Shell in ParaView 5.9.1 installed on my other machine with Ubuntu. Outside ParaView it does work.  
(matplotlib version 3.5.1).

---

<div class="post-metadata">

### Author: ![Matheus\_Viana](https://discourse.paraview.org/user_avatar/discourse.paraview.org/matheus_viana/32/8428_2.png) [@Matheus\_Viana](https://discourse.paraview.org/u/Matheus_Viana)
#### Post date: [January 26, 2022, 6:54pm UTC](https://discourse.paraview.org/t/output-messages-window-stop-working-after-running-a-macro-that-uses-matplotlib-macos/8837/18 "2022-01-26T18:54:46Z")

</div>

What issue is that?

---

<div class="post-metadata">

### Author: ![pavel](https://discourse.paraview.org/user_avatar/discourse.paraview.org/pavel/32/8287_2.png) [@pavel](https://discourse.paraview.org/u/pavel)
#### Post date: [January 26, 2022, 8:23pm UTC](https://discourse.paraview.org/t/output-messages-window-stop-working-after-running-a-macro-that-uses-matplotlib-macos/8837/19 "2022-01-26T20:23:40Z")

</div>

I just can not import matplotlib module inside Python shell or using macro. I think in my case smth wrong with environment settings regarding to Python. Tomorrow I’ll have an access to that machine and be able to put an error message here.

Edited:

 ![another_error](https://discourse.paraview.org/uploads/default/original/2X/5/58c9e34ad153e9771a3b2e88d97e577bc7a577a3.png)

---

<div class="post-metadata">

### Author: ![Matheus\_Viana](https://discourse.paraview.org/user_avatar/discourse.paraview.org/matheus_viana/32/8428_2.png) [@Matheus\_Viana](https://discourse.paraview.org/u/Matheus_Viana)
#### Post date: [February 2, 2022, 7:12pm UTC](https://discourse.paraview.org/t/output-messages-window-stop-working-after-running-a-macro-that-uses-matplotlib-macos/8837/20 "2022-02-02T19:12:52Z")

</div>

Hi @mwestphal. Could you please take a look at this issue?

[Next page](https://discourse.paraview.org/t/output-messages-window-stop-working-after-running-a-macro-that-uses-matplotlib-macos/8837.md?page=2)
