# Logout on Mac when using PyPlot (v1.2)

**URL:** https://discourse.julialang.org/t/logout-on-mac-when-using-pyplot-v1-2/27842
**Category:** General Usage
**Tags:** bug
**Created:** [August 22, 2019, 12:03pm UTC](https://discourse.julialang.org/t/logout-on-mac-when-using-pyplot-v1-2/27842 "2019-08-22T12:03:11Z")
**Posts on this page:** 10
**Page:** 1

<div class="post-metadata">

### Author: ![swishmas](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/swishmas/32/8803_2.png) [@swishmas](https://discourse.julialang.org/u/swishmas)
#### Post date: [August 22, 2019, 12:03pm UTC](https://discourse.julialang.org/t/logout-on-mac-when-using-pyplot-v1-2/27842/1 "2019-08-22T12:03:11Z")

</div>

Hi there,

I just updated to v1.2 and run the code

```julia
using PyPlot
plot([i for i = 1:20],[i^2 for i = 1:20])

```

And my Apple computer (Mojave, 2017) will log me out and close all my windows. Is there a crowd favorite plotting alternative that I could use as a temporary alternative in Julia?

---

<div class="post-metadata">

### Author: ![dmolina](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dmolina/32/5246_2.png) [@dmolina](https://discourse.julialang.org/u/dmolina)
#### Post date: [August 22, 2019, 1:19pm UTC](https://discourse.julialang.org/t/logout-on-mac-when-using-pyplot-v1-2/27842/2 "2019-08-22T13:19:50Z")

</div>

In my computer, not Apple, is working nicely.  
However, good alternatives are [Vegalite](https://github.com/queryverse/VegaLite.jl) or [Gadfly](http://gadflyjl.org/stable/) (and others). Try them.

By the way:

```julia
using PyPlot
plot(1:20, (1:20).^2)

```

is a simpler way to write it. Or using variables:

```julia
using PyPlot
x=1:20
plot(x, x.^2) 

```

---

<div class="post-metadata">

### Author: ![andrewning](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/andrewning/32/3661_2.png) [@andrewning](https://discourse.julialang.org/u/andrewning)
#### Post date: [September 1, 2019, 5:49am UTC](https://discourse.julialang.org/t/logout-on-mac-when-using-pyplot-v1-2/27842/3 "2019-09-01T05:49:04Z")

</div>

I’m seeing the same issue on both 1.1 and 1.2. This wasn’t a problem for me just a week ago. The only thing I can think of that I changed in the interim was updating macOS (a point update from 10.14.[4 or 5] to 10.14.6). I tried updating to Julia 1.2 but that didn’t fix the issue. If I plot within vscode rather than from a terminal REPL then it works fine. Pulling up figure windows from pyplot in python also works fine.

---

<div class="post-metadata">

### Author: ![cortner](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cortner/32/204_2.png) [@cortner](https://discourse.julialang.org/u/cortner)
#### Post date: [September 1, 2019, 9:07am UTC](https://discourse.julialang.org/t/logout-on-mac-when-using-pyplot-v1-2/27842/4 "2019-09-01T09:07:26Z")

</div>

I think It is the backend - one needs to change it. I’m afraid I don’t remember what i changed it to. (A mac specific one I think) I can look it up when I’m back at a desktop.

---

<div class="post-metadata">

### Author: ![stevengj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stevengj/32/71_2.png) [@stevengj](https://discourse.julialang.org/u/stevengj)
#### Post date: [September 1, 2019, 11:44am UTC](https://discourse.julialang.org/t/logout-on-mac-when-using-pyplot-v1-2/27842/5 "2019-09-01T11:44:54Z")

</div>

> [@swishmas](#):
>
> And my Apple computer (Mojave, 2017) will log me out and close all my windows.

I have a Mac running Mojave (10.14.5), and it works fine for me.

You can try doing

```julia
pkg> add Conda
julia> using Conda
julia> Conda.update()

```

in case something is broken or out of date with your Anaconda installation. (Then relaunch Julia and try PyPlot again.)

(Though honestly it is concerning to me that _any_ problem could cause MacOS to log you out. I’ve never heard of anything like that.)

---

<div class="post-metadata">

### Author: ![cortner](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cortner/32/204_2.png) [@cortner](https://discourse.julialang.org/u/cortner)
#### Post date: [September 1, 2019, 11:58am UTC](https://discourse.julialang.org/t/logout-on-mac-when-using-pyplot-v1-2/27842/6 "2019-09-01T11:58:01Z")

</div>

For the Record - this happened to me with a clean Ansconda installation just 2-3 weeks ago. I am fairly certain it was caused by the default backend.

---

<div class="post-metadata">

### Author: ![cortner](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cortner/32/204_2.png) [@cortner](https://discourse.julialang.org/u/cortner)
#### Post date: [September 1, 2019, 12:16pm UTC](https://discourse.julialang.org/t/logout-on-mac-when-using-pyplot-v1-2/27842/7 "2019-09-01T12:16:24Z")

</div>

I should add that this also happens with pure python. The backend `'backend': 'TkAgg'` leads to this crash. I just double-checked and confirmed this. In Python, I switch to the `MacOSX` backend,

```julia
import matplotlib.pyplot as plt
plt.switch_backend('MacOSX')

```

after which `matplotlib` plotting works fine without any issues.

_EDIT:_ following the Readme at [PyPlot.jl](https://github.com/JuliaPy/PyPlot.jl), the following works from Julia:

```julia
using PyCall
pygui(:qt5)
using PyPlot
x = range(0,1,length=100);
y = cos.(x);
plot(x,y)

```

But for practical purposes probably best to fix this in the [matplotlibrc file](https://matplotlib.org/users/customizing.html#the-matplotlibrc-file) : in `~/.matplotlib/matplotlibrc` just add the following line:

```julia
backend: qt5agg

```

---

<div class="post-metadata">

### Author: ![cortner](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cortner/32/204_2.png) [@cortner](https://discourse.julialang.org/u/cortner)
#### Post date: [September 1, 2019, 12:27pm UTC](https://discourse.julialang.org/t/logout-on-mac-when-using-pyplot-v1-2/27842/8 "2019-09-01T12:27:50Z")

</div>

[https://github.com/matplotlib/matplotlib/issues/14999](https://github.com/matplotlib/matplotlib/issues/14999)

---

<div class="post-metadata">

### Author: ![stevengj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stevengj/32/71_2.png) [@stevengj](https://discourse.julialang.org/u/stevengj)
#### Post date: [September 1, 2019, 5:51pm UTC](https://discourse.julialang.org/t/logout-on-mac-when-using-pyplot-v1-2/27842/9 "2019-09-01T17:51:09Z")

</div>

> [@cortner](#):
>
> I am fairly certain it was caused by the default backend.

The tkagg backend is known to be broken in MacOS ([TkAgg backend on macOS aborts · Issue #410 · JuliaPy/PyPlot.jl · GitHub](https://github.com/JuliaPy/PyPlot.jl/issues/410)) — this a known problem in Matplotlib ([Python with the 'TkAgg' backend on macOS crashes out when figure windows are moved · Issue #7743 · matplotlib/matplotlib · GitHub](https://github.com/matplotlib/matplotlib/issues/7743)) and is reportedly due to an upstream bug in the tkinter library ([Tk Toolkit / Read-Only Bugs / #3082 Crash on MoutainLion with negative offset to wm geometry](https://sourceforge.net/p/tktoolkit/bugs/3082/)).

As a result, back in April 2019 I changed PyPlot to not use tkagg by default anymore on MacOS ([don't default to tk on macos (closes #410) · JuliaPy/PyPlot.jl@6bd7b68 · GitHub](https://github.com/JuliaPy/PyPlot.jl/commit/6bd7b680e5db828b427cff66196d61deaa6cee7b)). So the only reason this would show up anymore is if you are explicitly requesting tkagg (either in your `.matplotlibrc` file or via the `MPLBACKEND` environment variable).

> [@cortner](#):
>
> But for practical purposes probably best to fix this in the [matplotlibrc file](https://matplotlib.org/users/customizing.html#the-matplotlibrc-file)

It is not necessary to change your `.matplotlibrc` file unless you were explicitly setting the backend to `tkagg`, which is not common.

---

<div class="post-metadata">

### Author: ![cortner](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cortner/32/204_2.png) [@cortner](https://discourse.julialang.org/u/cortner)
#### Post date: [September 1, 2019, 6:01pm UTC](https://discourse.julialang.org/t/logout-on-mac-when-using-pyplot-v1-2/27842/10 "2019-09-01T18:01:28Z")

</div>

It is possible but I don’t remember ever setting this to tkagg - I had assumed that the fresh anaconda install modified this setting. What I know for certain is that before the anaconda install PyPlot worked fine on my system.
