JuliaPy / PyPlot.jl

Plotting for Julia based on matplotlib.pyplot
https://github.com/JuliaPy/PyPlot.jl
MIT License
475 stars 87 forks source link

plotting causes SEGFAULT #419

Closed dlfivefifty closed 5 years ago

dlfivefifty commented 5 years ago
julia> versioninfo()
Julia Version 1.0.2
Commit d789231e99 (2018-11-08 20:11 UTC)
Platform Info:
  OS: macOS (x86_64-apple-darwin18.2.0)
  CPU: Intel(R) Core(TM) i7-7700HQ CPU @ 2.80GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-6.0.0 (ORCJIT, skylake)

julia> using PyPlot

julia> plot(1:10)
Segmentation fault: 11

A window briefly appears before the SEGFAULT.

cormullion commented 5 years ago

A bit more information from the crash on my mac:

julia-1.1> using PyPlot

julia-1.1> x = range(0; stop=2*pi, length=1000); y = sin.(3 * x + 4 * cos.(2 * x));

julia-1.1> plot(x, y, color="red", linewidth=2.0, linestyle="--")
2019-01-24 09:11:10.174 julia[662:29121764] -[NSApplication _setup:]: unrecognized selector sent to instance 0x7fbafd8318c0
2019-01-24 09:11:10.174 julia[662:29121764] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSApplication _setup:]: unrecognized selector sent to instance 0x7fbafd8318c0'
*** First throw call stack:
(
)
libc++abi.dylib: terminating with uncaught exception of type NSException

signal (6): Abort trap: 6
in expression starting at no file:0
__pthread_kill at /usr/lib/system/libsystem_kernel.dylib (unknown line)
Allocations: 12760827 (Pool: 12759145; Big: 1682); GC: 27
Abort trap: 6

using [d330b81b] PyPlot v2.7.0

Julia Version 1.1.0 Commit 80516ca202 (2019-01-21 21:24 UTC) Platform Info: OS: macOS (x86_64-apple-darwin14.5.0) (Mojave) CPU: Intel(R) Core(TM) i5-7500 CPU @ 3.40GHz WORD_SIZE: 64 LIBM: libopenlibm LLVM: libLLVM-6.0.1 (ORCJIT, skylake)

cormullion commented 5 years ago

(May be the same as https://github.com/JuliaPy/PyPlot.jl/issues/253.)

stevengj commented 5 years ago

It works fine for me on my Mac with the Conda python. What are PyPlot.backend and PyPlot.PyCall.python? I have:

julia> PyPlot.backend
"qt5agg"

julia> PyPlot.PyCall.python
"/Users/stevenj/.julia/conda/3/bin/python"
dlfivefifty commented 5 years ago

Exactly the same thing:

julia> PyPlot.backend
"qt5agg"

julia> PyPlot.PyCall.python
"/Users/solver/.julia/conda/3/bin/python"
stevengj commented 5 years ago

Does it work in Python? Try:

using PyCall
ENV["MPLBACKEND"]="qt5agg"
run(`$(PyCall.python) -c "import matplotlib.pyplot as plt; plt.plot([1,2,3,4]); plt.show()"`)
dlfivefifty commented 5 years ago

Yes, it works!

stevengj commented 5 years ago

I still can't reproduce. I'm using Julia 1.1.0 on macos 10.14, and I ran Conda.update() to make sure I'm using the latest Conda packages; can you try that?

dlfivefifty commented 5 years ago

Just did and still it crashes

stevengj commented 5 years ago

Are you using JuliaPro, the standard julialang.org download, or a custom build?

dlfivefifty commented 5 years ago

Julia 1.0.2 built from source with MKL:

julia> versioninfo()
Julia Version 1.0.2
Commit d789231e99 (2018-11-08 20:11 UTC)
Platform Info:
  OS: macOS (x86_64-apple-darwin18.2.0)
  CPU: Intel(R) Core(TM) i7-7700HQ CPU @ 2.80GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-6.0.0 (ORCJIT, skylake)
stevengj commented 5 years ago

Duplicate of JuliaPy/PyCall.jl#443.

Julia's MKL conflicts with the one used in NumPy.

stevengj commented 5 years ago

By the way, what does LinearAlgebra.BLAS.vendor() print for such builds? It might be nice to print a warning.

dlfivefifty commented 5 years ago
julia> LinearAlgebra.BLAS.vendor()
:mkl
stevengj commented 5 years ago

Warning added in JuliaPy/PyCall.jl#637