Skip to content

PyPlot causing "infinite loop" on julia 1.3 #453

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
scottstanie opened this issue Aug 8, 2019 · 6 comments
Closed

PyPlot causing "infinite loop" on julia 1.3 #453

scottstanie opened this issue Aug 8, 2019 · 6 comments

Comments

@scottstanie
Copy link

Can't seem to get PyPlot to work

(v1.3) pkg> add PyPlot
  Updating registry at `~/.julia/registries/General`
  Updating git-repo `https://github.com/JuliaRegistries/General.git`
 Resolving package versions...
  Updating `~/.julia/environments/v1.3/Project.toml`
  [d330b81b] + PyPlot v2.8.1
  Updating `~/.julia/environments/v1.3/Manifest.toml`
  [b964fa9f] + LaTeXStrings v1.0.3
  [d330b81b] + PyPlot v2.8.1
using PyPlot
[ Info: Recompiling stale cache file /home/scott/.julia/compiled/v1.3/PyPlot/oatAj.ji for PyPlot [d330b81b-6aea-500a-939a-2ce795aea3ee]

julia> plot(collect(1:5), rand(5))
error in background error handler:
out of stack space (infinite loop?)
    while executing
"::tcl::Bgerror {out of stack space (infinite loop?)} {-code 1 -level 0 -errorcode NONE -errorinfo {out of stack space (infinite loop?)
....


julia> versioninfo()
Julia Version 1.3.0-alpha.0
Commit 6c11e7c2c4 (2019-07-23 01:46 UTC)
Platform Info:
  OS: Linux (x86_64-pc-linux-gnu)
  CPU: Intel(R) Xeon(R) CPU E5-2680 v4 @ 2.40GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-6.0.1 (ORCJIT, broadwell)
Environment:
  JULIA_NUM_THREADS = 28
@scottstanie
Copy link
Author

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?

@scottstanie
Copy link
Author

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

@stevengj
Copy link
Member

stevengj commented Sep 2, 2019

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

@scottstanie
Copy link
Author

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?

@stevengj
Copy link
Member

stevengj commented Sep 3, 2019

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.

@jacob-roth
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants