Closed scottstanie closed 5 years ago
Just adding to this- I can get PyPlot to work by doing the conda install version with ENV["PYTHON"] = ""
]build PyCall
, then using PyPlot
, but if i try to build PyCall with my virtualenv python, I always get the infinite loop error.
Is there a way to use PyPlot with a virtualenv python, and not the conda one?
A workaround for me I found-
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()
even though PyCall recommends not doing this, it works and throws no error, while PyPlot continues to give errors with any virtualenv of python versions 3.4-3.7
tcl::Bgerror
sounds like a problem with the tcl (tkagg) backend. Can you try another backend?
e.g.
julia> ENV["MPLBACKEND"]="qt5agg"
julia> using PyPlot
Thank you @stevengj !
Is the easiest way to make this the default just adding export MPLBACKEND=qt5agg
to my .bashrc? Or is there another way to configure it?
You can configure it by creating a .matplotlibrc
file with a line backend: Qt5Agg
. Google "matplotlibrc" for more info.
The tcl backend is already broken on MacOS (#410) due to an upstream bug — it's concerning to hear that it may be broken on Linux too. Maybe I should just make qt5agg the default everywhere.
I ave a similar issue. From a fresh REPL:
julia> versioninfo()
Julia Version 1.7.3
Commit 742b9abb4d (2022-05-06 12:58 UTC)
Platform Info:
OS: macOS (x86_64-apple-darwin21.4.0)
CPU: Intel(R) Core(TM) i7-7820HQ CPU @ 2.90GHz
WORD_SIZE: 64
LIBM: libopenlibm
LLVM: libLLVM-12.0.1 (ORCJIT, skylake)
Environment:
JULIA_BINDIR = /Applications/Julia-1.7.app/Contents/Resources/julia/bin/
julia> ENV["PYTHON"] = "/Library/Frameworks/Python.framework/Versions/3.9/bin/python3"
"/Library/Frameworks/Python.framework/Versions/3.9/bin/python3"
julia> ENV["MPLBACKEND"]="qt5agg"
"qt5agg"
(@v1.7) pkg> add PyPlot
Updating registry at `~/.julia/registries/General.toml`
Resolving package versions...
No Changes to `~/.julia/environments/v1.7/Project.toml`
No Changes to `~/.julia/environments/v1.7/Manifest.toml`
(@v1.7) pkg> build PyPlot PyCall
Building Conda ─→ `~/.julia/scratchspaces/44cfe95a-1eb2-52ea-b672-e2afdf69b78f/6e47d11ea2776bc5627421d59cdcc1296c058071/build.log`
Building PyCall → `~/.julia/scratchspaces/44cfe95a-1eb2-52ea-b672-e2afdf69b78f/1fc929f47d7c151c839c5fc1375929766fb8edcc/build.log`
julia> using PyPlot
┌ Warning: PyPlot is using tkagg backend, which is known to cause crashes on MacOS (#410); use the MPLBACKEND environment variable to request a different backend.
└ @ PyPlot ~/.julia/packages/PyPlot/XaELc/src/init.jl:198
Can't seem to get PyPlot to work