JuliaPy / PyCall.jl

Package to call Python functions from the Julia language
MIT License
1.47k stars 187 forks source link

Error with QT Library When Calling `PyPlot` Uisng `PyCall` on Windows #889

Open RoyiAvital opened 3 years ago

RoyiAvital commented 3 years ago

I'm running the demo code on the README file:

plt = pyimport("matplotlib.pyplot")
x = range(0;stop=2*pi,length=1000); y = sin.(3*x + 4*cos.(2*x));
plt.plot(x, y, color="red", linewidth=2.0, linestyle="--")
plt.show()

I get the following error:

image

Then the REPL just crashes.

Could it be a missing installation by Conda or something? Using Julia 1.6 on Windows 10.

If I set:

mat = pyimport("matplotlib")
mat.use("TkAgg")

Then it works.

PallHaraldsson commented 3 years ago

FYI, fix here: https://www.dropboxforum.com/t5/Dropbox-installs-integrations/How-do-I-fix-the-Qt-platform-plugin-quot-windows-quot-error/td-p/91545

It's Windows/[ana]Conda related it seems, works for me on LInux.

RoyiAvital commented 3 years ago

But it used to work out of the box previously. I didn't need to manually install anything QT related.

RoyiAvital commented 3 years ago

By the way, PyQT is there (Basically QT5) in the Conda folder. It should use it but somehow it doesn't.

Could it be because I installed MatPlotLib using Conda and not PyPlot? Could it be that PyPlot would have download more dependencies and everything would work?

RoyiAvital commented 3 years ago

OK, I think I found some of the problems. It happened as I moved the installation folder of Julia.

In Conda folder there is a file called qt.conf which probably define the paths to the QT binaries. Since it uses absolute paths, when I moved the folders it failed.

I wonder if there is a way to make PyPlot and PyCall regenerate their configuration files which include paths.

See https://github.com/JuliaPy/PyCall.jl/issues/890.