# Help to debug PyCall plotting problem

**URL:** https://discourse.julialang.org/t/help-to-debug-pycall-plotting-problem/22683
**Category:** General Usage
**Tags:** pycall
**Created:** [April 3, 2019, 9:49am UTC](https://discourse.julialang.org/t/help-to-debug-pycall-plotting-problem/22683 "2019-04-03T09:49:07Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![angelv](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/angelv/32/133_2.png) [@angelv](https://discourse.julialang.org/u/angelv)
#### Post date: [April 3, 2019, 9:49am UTC](https://discourse.julialang.org/t/help-to-debug-pycall-plotting-problem/22683/1 "2019-04-03T09:49:07Z")

</div>

Hi,

first time using PyCall and I’m having problems generating plots with the Python package that I’m trying to use, but I’m not sure how to debug it.

The Python package I want to use is called ChiantiPy ([GitHub - chianti-atomic/ChiantiPy: ChiantiPy is a python package to calculate the radiative properties of astrophysical plasmas based on the CHIANTI atomic database](https://github.com/chianti-atomic/ChiantiPy))

In Python I just do (popPlot generates a figure):

```julia
import ChiantiPy.core as ch
import numpy as np
import matplotlib.pyplot as plt

t = 10.**(5.8 + 0.05*np.arange(21.))
fe14 = ch.ion('fe_14', temperature=t, eDensity=1.e+9, em=1.e+27)
fe14.popPlot()

```

In Julia I tried something similar:

```julia
using PyCall
ch = pyimport("ChiantiPy.core")
np = pyimport("numpy")
plt = pyimport("matplotlib.pyplot")

t = [10^i for i in 5.8 .+ 0.05 .* range(0.0,20.0,step=1)];
fe14 = ch.ion("fe_14", temperature=t, eDensity=1.e+9, em=1.e+27);
fe14.popPlot()
plt.show()

```

But when I run it, I get first this error about libGL, though I don’t think that is important?

```julia
julia> include("test.jl")                                                                                                                                                                                            
 found PyQt5 widgets                                                                                                                                                                                                 
 using PyQt5 widgets                                                                                                                                                                                                 
libGL error: No matching fbConfigs or visuals found                                                                                                                                                                  
libGL error: failed to load driver: swrast

```

then, a new window is created, where the figure should go, but no figure is shown. If I try to close it, then I get a warning from the system that “This window might be busy and is not responding. [etc]”.

If I close this window and later I try to generate the plot again via popPlot() then julia itself dies:

```julia
julia> fe14.popPlot()                                                                                                                                                                                                
The X11 connection broke: I/O error (code 1)                                                                                                                                                                         
XIO: fatal IO error 22 (Invalid argument) on X server ":0.0"                                                                                                                                                        
      after 483 requests (481 known processed) with 0 events remaining.                                                                                                                                              

```

Any suggestions on how to get this working properly?

Thanks,  
AdV

---

<div class="post-metadata">

### Author: ![tkf](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tkf/32/17635_2.png) [@tkf](https://discourse.julialang.org/u/tkf)
#### Post date: [April 3, 2019, 10:33am UTC](https://discourse.julialang.org/t/help-to-debug-pycall-plotting-problem/22683/2 "2019-04-03T10:33:41Z")

</div>

This sounds like [PyPlot works but calling matplotlib directly from PyCall aborts · Issue #665 · JuliaPy/PyCall.jl · GitHub](https://github.com/JuliaPy/PyCall.jl/issues/665)

If so, calling `PyCall.pygui_start(:qt_pyqt5)` before the `pyimport`s could help.

---

<div class="post-metadata">

### Author: ![angelv](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/angelv/32/133_2.png) [@angelv](https://discourse.julialang.org/u/angelv)
#### Post date: [April 3, 2019, 10:38am UTC](https://discourse.julialang.org/t/help-to-debug-pycall-plotting-problem/22683/3 "2019-04-03T10:38:43Z")

</div>

Hi, many thanks, indeed this solves the issue.

I had tried before pygui(:qt\_pyqt5) thinking that it was doing the same as what you suggested, but that didn’t fix it.

Many thanks,  
AdV
