# PyPlot does not show me any plot

**URL:** <https://discourse.julialang.org/t/pyplot-does-not-show-me-any-plot/113438>\
**Category:** New to Julia\
**Tags:** question, package, plotting\
**Created:** [April 24, 2024, 11:51am UTC](https://discourse.julialang.org/t/pyplot-does-not-show-me-any-plot/113438 "2024-04-24T11:51:03Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Andrea\_Demaria](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/andrea_demaria/32/205427_2.png) [@Andrea\_Demaria](https://discourse.julialang.org/u/Andrea_Demaria)\
**Post date:** [April 24, 2024, 11:51am UTC](https://discourse.julialang.org/t/pyplot-does-not-show-me-any-plot/113438/1 "2024-04-24T11:51:03Z")

</div>

I installed Julia 1.9.3 on my windows 11 pc and add the package `PyPlot`. Then, going in VS code the Julia version is immediately recognize (so okay). Whenever I write `using PyPlot` all works well, but when I try to make a very simple plot, for example `plot(rand(5))` including `gcf()` the code run and run without stopping and show me the plot. How can I fix the problem? Writing instead the same lines of code in the REPL it seems to appear the plot, but then all close automatically.

Thanks in advance for all suggestions!

---

<div class="post-metadata">

**Author:** ![jd-foster](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jd-foster/32/35824_2.png) [@jd-foster](https://discourse.julialang.org/u/jd-foster)\
**Post date:** [April 24, 2024, 12:35pm UTC](https://discourse.julialang.org/t/pyplot-does-not-show-me-any-plot/113438/2 "2024-04-24T12:35:20Z")

</div>

Welcome to the forum.  
If you can’t find out the cause of the problem, you could also try [PythonPlot.jl](https://github.com/JuliaPy/PythonPlot.jl) instead. It might be more reliable and it uses the same plotting library.

---

<div class="post-metadata">

**Author:** ![Andrea\_Demaria](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/andrea_demaria/32/205427_2.png) [@Andrea\_Demaria](https://discourse.julialang.org/u/Andrea_Demaria)\
**Post date:** [April 24, 2024, 12:47pm UTC](https://discourse.julialang.org/t/pyplot-does-not-show-me-any-plot/113438/3 "2024-04-24T12:47:56Z")

</div>

I considered that solution, as well as also `Plots`, and both work. The problem is that I have to run codes that are written with `PyPlot` and just replace the name of the package does not work since seems that they have different commands. On my old computer all goes well, but when I installed on my new pc the problem start.

---

<div class="post-metadata">

**Author:** ![jd-foster](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jd-foster/32/35824_2.png) [@jd-foster](https://discourse.julialang.org/u/jd-foster)\
**Post date:** [April 24, 2024, 1:29pm UTC](https://discourse.julialang.org/t/pyplot-does-not-show-me-any-plot/113438/4 "2024-04-24T13:29:26Z")

</div>

Code for PyPlot should be mostly compatible with PythonPlot, with some small differences described [here:](https://github.com/JuliaPy/PythonPlot.jl/?tab=readme-ov-file#differences-from-pyplotjl)

---

<div class="post-metadata">

**Author:** ![ufechner7](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ufechner7/32/51363_2.png) [@ufechner7](https://discourse.julialang.org/u/ufechner7)\
**Post date:** [April 24, 2024, 2:09pm UTC](https://discourse.julialang.org/t/pyplot-does-not-show-me-any-plot/113438/5 "2024-04-24T14:09:25Z")

</div>

I prefer to stick to PyPlot.jl, and it works fine for me (using Julia 1.10.2).

If there is a problem with PyPlot.jl, often the following command helps:

```julia
using Pkg
Pkg.build("PyCall")

```

---

<div class="post-metadata">

**Author:** ![Andrea\_Demaria](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/andrea_demaria/32/205427_2.png) [@Andrea\_Demaria](https://discourse.julialang.org/u/Andrea_Demaria)\
**Post date:** [April 24, 2024, 3:41pm UTC](https://discourse.julialang.org/t/pyplot-does-not-show-me-any-plot/113438/6 "2024-04-24T15:41:29Z")

</div>

Thanks a lot, this now work, to be honest I think that it’s not the better solution, but since it works it’s fine 😁. Thanks!!

---

<div class="post-metadata">

**Author:** ![Andrea\_Demaria](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/andrea_demaria/32/205427_2.png) [@Andrea\_Demaria](https://discourse.julialang.org/u/Andrea_Demaria)\
**Post date:** [April 24, 2024, 3:45pm UTC](https://discourse.julialang.org/t/pyplot-does-not-show-me-any-plot/113438/7 "2024-04-24T15:45:18Z")

</div>

Thanks for the suggestion, but it seems that nothing happens, I attach the output on the REPL

> julia\> using Pkg  
> julia\> Pkg.build(“PyCall”)  
> Building Conda ─→ `C:\Users\Andrea\.julia\scratchspaces\44cfe95a-1eb2-52ea-b672-e2afdf69b78f\51cab8e982c5b598eea9c8ceaced4b58d9dd37c9\build.log`  
> Building PyCall → `C:\Users\Andrea\.julia\scratchspaces\44cfe95a-1eb2-52ea-b672-e2afdf69b78f\9816a3826b0ebf49ab4926e2b18842ad8b5c8f04\build.log`

After doing this when I try to make a plot with PyPlot all is as before.

---

<div class="post-metadata">

**Author:** ![mkitti](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mkitti/32/12459_2.png) [@mkitti](https://discourse.julialang.org/u/mkitti)\
**Post date:** [April 24, 2024, 7:15pm UTC](https://discourse.julialang.org/t/pyplot-does-not-show-me-any-plot/113438/8 "2024-04-24T19:15:51Z")

</div>

For PyPlot, you likely need to (re)configure to use a particular Python. PythonPlot creates a new environment for each Julia environment.

---

<div class="post-metadata">

**Author:** ![Paul\_Soderlind](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/paul_soderlind/32/1753_2.png) [@Paul\_Soderlind](https://discourse.julialang.org/u/Paul_Soderlind)\
**Post date:** [April 24, 2024, 7:23pm UTC](https://discourse.julialang.org/t/pyplot-does-not-show-me-any-plot/113438/9 "2024-04-24T19:23:46Z")

</div>

PyPlot uses Python/matplotlib so you need to have those installed. Once you have that, you can do

```julia
using PyPlot
figure()
plot(1:10)
display(gcf()) #to force VScode to show the plot. may not be needed

```

---

<div class="post-metadata">

**Author:** ![ufechner7](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ufechner7/32/51363_2.png) [@ufechner7](https://discourse.julialang.org/u/ufechner7)\
**Post date:** [April 24, 2024, 9:59pm UTC](https://discourse.julialang.org/t/pyplot-does-not-show-me-any-plot/113438/10 "2024-04-24T21:59:53Z")

</div>

> [@Paul\_Soderlind](#):
>
> PyPlot uses Python/matplotlib so you need to have those installed.

Not entirely true. If you do:

```julia
ENV["PYTHON"]=""
Pkg.build("PyCall")

```

and then install PyPlot a version on Python + Matplotlib gets installed just for Julia projects…
