Skip to content
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

Failed to compile PyPlot #226

Closed
bliang26 opened this issue Apr 15, 2019 · 9 comments · Fixed by #304
Closed

Failed to compile PyPlot #226

bliang26 opened this issue Apr 15, 2019 · 9 comments · Fixed by #304

Comments

@bliang26
Copy link

I was trying to compile PyPlot with

  julia>  compile_package("PyPlot"; force=false, reuse=false)

but got the following error message:

Please submit a bug report with steps to reproduce this fault, and any error messages that follow (in their entirety). Thanks.
Exception: EXCEPTION_ACCESS_VIOLATION at 0x5c4140c5 -- PyUnicode_InternInPlace at C:\Users\bliang26\.julia\conda\3\python36.dll (unknown line)
in expression starting at C:\Users\bliang26\.julia\packages\PackageCompiler\oT98U\sysimg\precompile.jl:18
PyUnicode_InternInPlace at C:\Users\bliang26\.julia\conda\3\python36.dll (unknown line)
PyUnicode_InternFromString at C:\Users\bliang26\.julia\conda\3\python36.dll (unknown line)
PyImport_Import at C:\Users\bliang26\.julia\conda\3\python36.dll (unknown line)
PyImport_ImportModule at C:\Users\bliang26\.julia\conda\3\python36.dll (unknown line)
_pyimport at C:\Users\bliang26\.julia\packages\PyCall\ttONZ\src\PyCall.jl:469
pyimport at C:\Users\bliang26\.julia\packages\PyCall\ttONZ\src\PyCall.jl:493
pyimport_conda at C:\Users\bliang26\.julia\packages\PyCall\ttONZ\src\PyCall.jl:702
jl_fptr_trampoline at /home/Administrator/buildbot/worker/package_win64/build/src\gf.c:1864
jl_apply_generic at /home/Administrator/buildbot/worker/package_win64/build/src\gf.c:2219 [inlined]
jl_apply at /home/Administrator/buildbot/worker/package_win64/build/src\julia.h:1571 [inlined]
jl_invoke at /home/Administrator/buildbot/worker/package_win64/build/src\gf.c:56
pyimport_conda at C:\Users\bliang26\.julia\packages\PyCall\ttONZ\src\PyCall.jl:701 [inlined]
__init__ at C:\Users\bliang26\.julia\packages\PyPlot\cdCMF\src\init.jl:169
jl_fptr_trampoline at /home/Administrator/buildbot/worker/package_win64/build/src\gf.c:1864
jl_apply_generic at /home/Administrator/buildbot/worker/package_win64/build/src\gf.c:2219
top-level scope at C:\Users\bliang26\.julia\packages\PackageCompiler\oT98U\sysimg\precompile.jl:19 [inlined]
top-level scope at .\none:0
jl_fptr_trampoline at /home/Administrator/buildbot/worker/package_win64/build/src\gf.c:1864
jl_toplevel_eval_flex at /home/Administrator/buildbot/worker/package_win64/build/src\toplevel.c:758
jl_parse_eval_all at /home/Administrator/buildbot/worker/package_win64/build/src\ast.c:883
jl_load at /home/Administrator/buildbot/worker/package_win64/build/src\toplevel.c:826 [inlined]
jl_load_ at /home/Administrator/buildbot/worker/package_win64/build/src\toplevel.c:833
include at .\boot.jl:326 [inlined]
include_relative at .\loading.jl:1038
include at .\sysimg.jl:29
jl_apply_generic at /home/Administrator/buildbot/worker/package_win64/build/src\gf.c:2219
do_call at /home/Administrator/buildbot/worker/package_win64/build/src\interpreter.c:323
eval_value at /home/Administrator/buildbot/worker/package_win64/build/src\interpreter.c:411
eval_stmt_value at /home/Administrator/buildbot/worker/package_win64/build/src\interpreter.c:362 [inlined]
eval_body at /home/Administrator/buildbot/worker/package_win64/build/src\interpreter.c:755
jl_interpret_toplevel_thunk_callback at /home/Administrator/buildbot/worker/package_win64/build/src\interpreter.c:885
unknown function (ip: FFFFFFFFFFFFFFFE)
unknown function (ip: 00000000082D339F)
unknown function (ip: 0000000000000000)
jl_toplevel_eval_flex at /home/Administrator/buildbot/worker/package_win64/build/src\toplevel.c:764
jl_toplevel_eval at /home/Administrator/buildbot/worker/package_win64/build/src\toplevel.c:773 [inlined]
jl_toplevel_eval_in at /home/Administrator/buildbot/worker/package_win64/build/src\toplevel.c:793
eval at .\boot.jl:328
jl_fptr_trampoline at /home/Administrator/buildbot/worker/package_win64/build/src\gf.c:1864
jl_apply_generic at /home/Administrator/buildbot/worker/package_win64/build/src\gf.c:2219
do_call at /home/Administrator/buildbot/worker/package_win64/build/src\interpreter.c:323
eval_value at /home/Administrator/buildbot/worker/package_win64/build/src\interpreter.c:411
eval_stmt_value at /home/Administrator/buildbot/worker/package_win64/build/src\interpreter.c:362 [inlined]
eval_body at /home/Administrator/buildbot/worker/package_win64/build/src\interpreter.c:755
jl_interpret_toplevel_thunk_callback at /home/Administrator/buildbot/worker/package_win64/build/src\interpreter.c:885
unknown function (ip: FFFFFFFFFFFFFFFE)
unknown function (ip: 00000000082D316F)
unknown function (ip: 0000000000000002)
jl_toplevel_eval_flex at /home/Administrator/buildbot/worker/package_win64/build/src\toplevel.c:764
jl_parse_eval_all at /home/Administrator/buildbot/worker/package_win64/build/src\ast.c:883
jl_load at /home/Administrator/buildbot/worker/package_win64/build/src\toplevel.c:826 [inlined]
jl_load_ at /home/Administrator/buildbot/worker/package_win64/build/src\toplevel.c:833
include at .\boot.jl:326 [inlined]
include_relative at .\loading.jl:1038
include at .\sysimg.jl:29
jl_fptr_trampoline at /home/Administrator/buildbot/worker/package_win64/build/src\gf.c:1864
jl_apply_generic at /home/Administrator/buildbot/worker/package_win64/build/src\gf.c:2219
exec_options at .\client.jl:267
_start at .\client.jl:436
jl_fptr_trampoline at /home/Administrator/buildbot/worker/package_win64/build/src\gf.c:1864
jl_apply_generic at /home/Administrator/buildbot/worker/package_win64/build/src\gf.c:2219
jl_apply at /home/Administrator/buildbot/worker/package_win64/build/src\julia.h:1571 [inlined]
true_main at /home/Administrator/buildbot/worker/package_win64/build/ui\repl.c:96
wmain at /home/Administrator/buildbot/worker/package_win64/build/ui\repl.c:217
__tmainCRTStartup at /usr/src/debug/mingw64-x86_64-runtime-5.0.3-1/crt\crtexe.c:329
mainCRTStartup at /usr/src/debug/mingw64-x86_64-runtime-5.0.3-1/crt\crtexe.c:212
BaseThreadInitThunk at C:\WINDOWS\System32\KERNEL32.DLL (unknown line)
RtlUserThreadStart at C:\WINDOWS\SYSTEM32\ntdll.dll (unknown line)
Allocations: 8947621 (Pool: 8945343; Big: 2278); GC: 18
ERROR: failed process: Process(`'C:\Users\bliang26\AppData\Local\Julia-1.1.0\bin\julia.exe' '--sysimage=C:\Users\bliang26\.julia\packages\PackageCompiler\oT98U\sysimg\backup\native\sys.dll' --output-o=sys.a --track-allocation=none --code-coverage=none --history-file=yes --inline=yes --math-mode=ieee --compile=yes --track-allocation=none --sysimage-native-code=yes '--sysimage=C:\Users\bliang26\AppData\Local\Julia-1.1.0\lib\julia\sys.dll' --compiled-modules=yes --optimize=2 'C:\Users\bliang26\.julia\packages\PackageCompiler\oT98U\sysimg\run_julia_code.jl'`, ProcessExited(1)) [1]
Stacktrace:
 [1] error(::String, ::Base.Process, ::String, ::Int64, ::String) at .\error.jl:42
 [2] pipeline_error at .\process.jl:785 [inlined]
 [3] #run#515(::Bool, ::Function, ::Cmd) at .\process.jl:726
 [4] run at .\process.jl:724 [inlined]
 [5] #run_julia#1 at C:\Users\bliang26\.julia\packages\PackageCompiler\oT98U\src\compiler_flags.jl:225 [inlined]
 [6] #run_julia at .\none:0 [inlined]
 [7] (::getfield(PackageCompiler, Symbol("##13#14")){Base.Iterators.Pairs{Symbol,Any,NTuple{14,Symbol},NamedTuple{(:sysimage, :startup_file, :handle_signals, :sysimage_native_code, :compiled_modules, :depwarn, :warn_overwrite, :compile, :cpu_target, :optimize, :debug_level, :inline, :check_bounds, :math_mode),Tuple{String,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing}}},String})() at C:\Users\bliang26\.julia\packages\PackageCompiler\oT98U\src\static_julia.jl:262
 [8] cd(::getfield(PackageCompiler, Symbol("##13#14")){Base.Iterators.Pairs{Symbol,Any,NTuple{14,Symbol},NamedTuple{(:sysimage, :startup_file, :handle_signals, :sysimage_native_code, :compiled_modules, :depwarn, :warn_overwrite, :compile, :cpu_target, :optimize, :debug_level, :inline, :check_bounds, :math_mode),Tuple{String,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing}}},String}, ::String) at .\file.jl:85
 [9] #build_object#12(::Base.Iterators.Pairs{Symbol,Any,NTuple{14,Symbol},NamedTuple{(:sysimage, :startup_file, :handle_signals, :sysimage_native_code, :compiled_modules, :depwarn, :warn_overwrite, :compile, :cpu_target, :optimize, :debug_level, :inline, :check_bounds, :math_mode),Tuple{String,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing}}}, ::Function, ::String, ::String, ::String, ::Bool) at C:\Users\bliang26\.julia\packages\PackageCompiler\oT98U\src\static_julia.jl:261
 [10] #build_object at .\none:0 [inlined]
 [11] build_object(::String, ::String, ::String, ::Bool, ::String, ::Nothing, ::Nothing, ::Nothing, ::Nothing, ::Nothing, ::Nothing, ::Nothing, ::Nothing, ::Nothing, ::Nothing, ::Nothing, ::Nothing, ::Nothing, ::Nothing) at C:\Users\bliang26\.julia\packages\PackageCompiler\oT98U\src\static_julia.jl:240
 [12] #static_julia#5(::Nothing, ::Bool, ::Bool, ::String, ::String, ::Nothing, ::Bool, ::Bool, ::Bool, ::Bool, ::Bool, ::Bool, ::Bool, ::Bool, ::Nothing, ::Bool, ::Bool, ::String, ::Nothing, ::Nothing, ::Nothing, ::Nothing, ::Nothing, ::Nothing, ::Nothing, ::Nothing, ::Nothing, ::Nothing, ::Nothing, ::Nothing, ::Nothing, ::Nothing, ::Nothing, ::Nothing, ::typeof(static_julia), ::String) at C:\Users\bliang26\.julia\packages\PackageCompiler\oT98U\src\static_julia.jl:161
 [13] #static_julia at .\none:0 [inlined]
 [14] #build_sysimg#29(::Bool, ::Bool, ::Bool, ::Nothing, ::Nothing, ::Nothing, ::Nothing, ::Nothing, ::Nothing, ::Nothing, ::Nothing, ::Nothing, ::Nothing, ::Nothing, ::Nothing, ::Nothing, ::Nothing, ::Nothing, ::Nothing, ::typeof(PackageCompiler.build_sysimg), ::String, ::String) at C:\Users\bliang26\.julia\packages\PackageCompiler\oT98U\src\api.jl:25
 [15] #build_sysimg at .\none:0 [inlined]
 [16] #compile_package#67(::Bool, ::Bool, ::Bool, ::Nothing, ::Bool, ::Function, ::Tuple{String,String}) at C:\Users\bliang26\.julia\packages\PackageCompiler\oT98U\src\PackageCompiler.jl:130
 [17] #compile_package at .\none:0 [inlined]
 [18] #compile_package#64 at C:\Users\bliang26\.julia\packages\PackageCompiler\oT98U\src\PackageCompiler.jl:94 [inlined]
 [19] (::getfield(PackageCompiler, Symbol("#kw##compile_package")))(::NamedTuple{(:force, :reuse),Tuple{Bool,Bool}}, ::typeof(compile_package), ::String) at .\none:0
 [20] top-level scope at none:0

PyCall was set up by the Conda.jl package. And here's my version info:

julia> versioninfo()
Julia Version 1.1.0
Commit 80516ca202 (2019-01-21 21:24 UTC)
Platform Info:
  OS: Windows (x86_64-w64-mingw32)
  CPU: Intel(R) Xeon(R) Gold 5118 CPU @ 2.30GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-6.0.1 (ORCJIT, skylake)
@asinghvi17
Copy link
Contributor

asinghvi17 commented Apr 15, 2019

You may want to raise this on www.github.com/JuliaPy/PyCall.jl as well...

@bliang26
Copy link
Author

Sure, I will try asking there.

@tkf
Copy link
Member

tkf commented Apr 16, 2019

I wonder what is in C:\Users\bliang26\.julia\packages\PackageCompiler\oT98U\sysimg\run_julia_code.jl, C:\Users\bliang26\.julia\packages\PackageCompiler\oT98U\sysimg\precompile.jl, and the files included from them (if any). It could be due to #192; i.e., PyCall.__init__ is not called before PyPlot.__init__. It would mean to call CPython API without initializing it and explain why there is a crash. A possible workaround would be to do compile_package("PyCall", "PyPlot"; force=false, reuse=false) although I'm not sure if it would work (I can't test this in my machine due to JuliaLang/julia#31156).

@bliang26
Copy link
Author

bliang26 commented Apr 16, 2019

The workaround helped but then I got the following error. By looking at #148 this seems to be related to global variables. After taking care of all global variables as suggested in #148 (I thought I did) in PyPlot.jl I still got the same error. Any ideas? Thanks.

fatal: error thrown and no exception handler available.
ErrorException("Task cannot be serialized")
rec_backtrace at /home/Administrator/buildbot/worker/package_win64/build/src\stackwalk.c:94
record_backtrace at /home/Administrator/buildbot/worker/package_win64/build/src\task.c:217 [inlined]
jl_throw at /home/Administrator/buildbot/worker/package_win64/build/src\task.c:417
jl_error at /home/Administrator/buildbot/worker/package_win64/build/src\rtutils.c:41
jl_serialize_value_ at /home/Administrator/buildbot/worker/package_win64/build/src\staticdata.c:294
jl_serialize_value_ at /home/Administrator/buildbot/worker/package_win64/build/src\staticdata.c:252 [inlined]
jl_serialize_value_ at /home/Administrator/buildbot/worker/package_win64/build/src\staticdata.c:286
jl_serialize_value_ at /home/Administrator/buildbot/worker/package_win64/build/src\julia.h:915 [inlined]
jl_serialize_value_ at /home/Administrator/buildbot/worker/package_win64/build/src\staticdata.c:303
jl_serialize_value_ at /home/Administrator/buildbot/worker/package_win64/build/src\julia.h:915 [inlined]
jl_serialize_value_ at /home/Administrator/buildbot/worker/package_win64/build/src\staticdata.c:303
jl_serialize_value_ at /home/Administrator/buildbot/worker/package_win64/build/src\staticdata.c:252 [inlined]
jl_serialize_value_ at /home/Administrator/buildbot/worker/package_win64/build/src\staticdata.c:286
jl_serialize_value_ at /home/Administrator/buildbot/worker/package_win64/build/src\julia.h:915 [inlined]
jl_serialize_value_ at /home/Administrator/buildbot/worker/package_win64/build/src\staticdata.c:303
jl_serialize_value_ at /home/Administrator/buildbot/worker/package_win64/build/src\staticdata.c:252 [inlined]
jl_serialize_module at /home/Administrator/buildbot/worker/package_win64/build/src\staticdata.c:230 [inlined]
jl_serialize_value_ at /home/Administrator/buildbot/worker/package_win64/build/src\staticdata.c:291
jl_serialize_value_ at /home/Administrator/buildbot/worker/package_win64/build/src\staticdata.c:252 [inlined]
jl_serialize_module at /home/Administrator/buildbot/worker/package_win64/build/src\staticdata.c:232 [inlined]
jl_serialize_value_ at /home/Administrator/buildbot/worker/package_win64/build/src\staticdata.c:291
jl_serialize_value_ at /home/Administrator/buildbot/worker/package_win64/build/src\staticdata.c:252 [inlined]
jl_serialize_module at /home/Administrator/buildbot/worker/package_win64/build/src\staticdata.c:230 [inlined]
jl_serialize_value_ at /home/Administrator/buildbot/worker/package_win64/build/src\staticdata.c:291
jl_serialize_module at /home/Administrator/buildbot/worker/package_win64/build/src\staticdata.c:222 [inlined]
jl_serialize_value_ at /home/Administrator/buildbot/worker/package_win64/build/src\staticdata.c:291
jl_serialize_value_ at /home/Administrator/buildbot/worker/package_win64/build/src\staticdata.c:337 [inlined]
jl_save_system_image_to_stream at /home/Administrator/buildbot/worker/package_win64/build/src\staticdata.c:1273
jl_create_system_image at /home/Administrator/buildbot/worker/package_win64/build/src\staticdata.c:1378
jl_write_compiler_output at /home/Administrator/buildbot/worker/package_win64/build/src\precompile.c:76
jl_atexit_hook at /home/Administrator/buildbot/worker/package_win64/build/src/home/Administrator/buildbot/worker/package_win64/build/src\init.c:222
wmain at /home/Administrator/buildbot/worker/package_win64/build/ui\repl.c:218
__tmainCRTStartup at /usr/src/debug/mingw64-x86_64-runtime-5.0.3-1/crt\crtexe.c:329
mainCRTStartup at /usr/src/debug/mingw64-x86_64-runtime-5.0.3-1/crt\crtexe.c:212
BaseThreadInitThunk at C:\WINDOWS\System32\KERNEL32.DLL (unknown line)
RtlUserThreadStart at C:\WINDOWS\SYSTEM32\ntdll.dll (unknown line)
ERROR: failed process: Process(`'C:\Users\bliang26\AppData\Local\Julia-1.1.0\bin\julia.exe' '--sysimage=C:\Users\bliang26\.julia\dev\PackageCompiler\sysimg\backup\native\sys.dll' --output-o=sys.a --track-allocation=none --code-coverage=none --history-file=yes --inline=yes --math-mode=ieee --compile=yes --track-allocation=none --sysimage-native-code=yes '--sysimage=C:\Users\bliang26\AppData\Local\Julia-1.1.0\lib\julia\sys.dll' --compiled-modules=yes --optimize=2 'C:\Users\bliang26\.julia\dev\PackageCompiler\sysimg\run_julia_code.jl'`, ProcessExited(1)) [1]
Stacktrace:
 [1] error(::String, ::Base.Process, ::String, ::Int64, ::String) at .\error.jl:42
 [2] pipeline_error at .\process.jl:785 [inlined]
 [3] #run#515(::Bool, ::Function, ::Cmd) at .\process.jl:726
 [4] run at .\process.jl:724 [inlined]
 [5] #run_julia#1 at C:\Users\bliang26\.julia\dev\PackageCompiler\src\compiler_flags.jl:225 [inlined]
 [6] #run_julia at .\none:0 [inlined]
 [7] (::getfield(PackageCompiler, Symbol("##13#14")){Base.Iterators.Pairs{Symbol,Any,NTuple{14,Symbol},NamedTuple{(:sysimage, :startup_file, :handle_signals, :sysimage_native_code, :compiled_modules, :depwarn, :warn_overwrite, :compile, :cpu_target, :optimize, :debug_level, :inline, :check_bounds, :math_mode),Tuple{String,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing}}},String})() at C:\Users\bliang26\.julia\dev\PackageCompiler\src\static_julia.jl:262
 [8] cd(::getfield(PackageCompiler, Symbol("##13#14")){Base.Iterators.Pairs{Symbol,Any,NTuple{14,Symbol},NamedTuple{(:sysimage, :startup_file, :handle_signals, :sysimage_native_code, :compiled_modules, :depwarn, :warn_overwrite, :compile, :cpu_target, :optimize, :debug_level, :inline, :check_bounds, :math_mode),Tuple{String,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing}}},String}, ::String) at .\file.jl:85
 [9] #build_object#12(::Base.Iterators.Pairs{Symbol,Any,NTuple{14,Symbol},NamedTuple{(:sysimage, :startup_file, :handle_signals, :sysimage_native_code, :compiled_modules, :depwarn, :warn_overwrite, :compile, :cpu_target, :optimize, :debug_level, :inline, :check_bounds, :math_mode),Tuple{String,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing}}}, ::Function, ::String, ::String, ::String, ::Bool) at C:\Users\bliang26\.julia\dev\PackageCompiler\src\static_julia.jl:261
 [10] #build_object at .\none:0 [inlined]
 [11] build_object(::String, ::String, ::String, ::Bool, ::String, ::Nothing, ::Nothing, ::Nothing, ::Nothing, ::Nothing, ::Nothing, ::Nothing, ::Nothing, ::Nothing, ::Nothing, ::Nothing, ::Nothing, ::Nothing, ::Nothing) at C:\Users\bliang26\.julia\dev\PackageCompiler\src\static_julia.jl:240
 [12] #static_julia#5(::Nothing, ::Bool, ::Bool, ::String, ::String, ::Nothing, ::Bool, ::Bool, ::Bool, ::Bool, ::Bool, ::Bool, ::Bool, ::Bool, ::Nothing, ::Bool, ::Bool, ::String, ::Nothing, ::Nothing, ::Nothing, ::Nothing, ::Nothing, ::Nothing, ::Nothing, ::Nothing, ::Nothing, ::Nothing, ::Nothing, ::Nothing, ::Nothing, ::Nothing, ::Nothing, ::Nothing, ::typeof(static_julia), ::String) at C:\Users\bliang26\.julia\dev\PackageCompiler\src\static_julia.jl:161
 [13] #static_julia at .\none:0 [inlined]
 [14] #build_sysimg#29(::Bool, ::Bool, ::Bool, ::Nothing, ::Nothing, ::Nothing, ::Nothing, ::Nothing, ::Nothing, ::Nothing, ::Nothing, ::Nothing, ::Nothing, ::Nothing, ::Nothing, ::Nothing, ::Nothing, ::Nothing, ::Nothing, ::typeof(PackageCompiler.build_sysimg), ::String, ::String) at C:\Users\bliang26\.julia\dev\PackageCompiler\src\api.jl:25
 [15] #build_sysimg at .\none:0 [inlined]
 [16] #compile_package#67(::Bool, ::Bool, ::Bool, ::Nothing, ::Bool, ::Function, ::Tuple{String,String}, ::Vararg{Tuple{String,String},N} where N) at C:\Users\bliang26\.julia\dev\PackageCompiler\src\PackageCompiler.jl:130
 [17] (::getfield(PackageCompiler, Symbol("#kw##compile_package")))(::NamedTuple{(:force, :reuse),Tuple{Bool,Bool}}, ::typeof(compile_package), ::Tuple{String,String}, ::Vararg{Tuple{String,String},N} where N) at .\none:0
 [18] #compile_package#64(::Base.Iterators.Pairs{Symbol,Bool,Tuple{Symbol,Symbol},NamedTuple{(:force, :reuse),Tuple{Bool,Bool}}}, ::Function, ::String, ::Vararg{String,N} where N) at C:\Users\bliang26\.julia\dev\PackageCompiler\src\PackageCompiler.jl:94
 [19] (::getfield(PackageCompiler, Symbol("#kw##compile_package")))(::NamedTuple{(:force, :reuse),Tuple{Bool,Bool}}, ::typeof(compile_package), ::String, ::Vararg{String,N} where N) at .\none:0
 [20] top-level scope at none:0

@tkf
Copy link
Member

tkf commented Apr 16, 2019

Hmm... I guess it's something to do with the GUI event loop in PyCall (although I think we are stopping the event loop via atexit hook).

@tkf
Copy link
Member

tkf commented Apr 17, 2019

It looks like you can workaround this by ENV["MPLBACKEND"] = "agg".

I checked it with the following changes in PyCall:

$ git diff master
diff --git a/aot/compile.jl b/aot/compile.jl
index 63d0cb7..a71415d 100755
--- a/aot/compile.jl
+++ b/aot/compile.jl
@@ -9,6 +9,7 @@ Pkg.activate(@__DIR__)
 Pkg.add("MacroTools")
 Pkg.develop(PackageSpec(name="PyCall", path=dirname(@__DIR__)))
 Pkg.build("PyCall")
+Pkg.add("PyPlot")
 Pkg.activate()

 using PackageCompiler
diff --git a/aot/precompile.jl b/aot/precompile.jl
index cb63b73..4ba69e3 100644
--- a/aot/precompile.jl
+++ b/aot/precompile.jl
@@ -14,3 +14,6 @@ isdefined(MacroTools, :__init__) && MacroTools.__init__()
 using PyCall
 PyCall.__init__()
 PyCall.pyimport("sys")[:executable]
+
+using PyPlot
+PyPlot.__init__()

$ MPLBACKEND=agg aot/compile.jl --color=yes
...
[ Info: System image: /home/takafumi/.julia/dev/PyCall/aot/sys.so

So, this part seems to be an issue in PyCall and/or PyPlot.

@bliang26
Copy link
Author

Awesome! How did you find out? The error message didn't show any clue. This definitely works, but the problem is that no figure shows up as I plot since the agg backend is for non-interactive use. If I switch to other interactive backends such as qt5agg I still got the same error message. Could you let me know how did you debug it so that maybe I can give it a try. Thanks.

@tkf
Copy link
Member

tkf commented Apr 18, 2019

How did you find out?

I thought Task cannot be serialized error was due to Task instance stored in some global state. PyCall uses Task (via Timer) for setting up GUI so I thought it could be solved by skipping the GUI setup in PyPlot (agg is the non-GUI backend).

the problem is that no figure shows up as I plot since the agg backend is for non-interactive use

I observe this too. The strange thing is that both matplotlib and PyPlot.jl report that they have the correct GUI backend. Also, re-starting the GUI with

using PyCall
pygui_stop_all()
pygui_start(:tk)  # pygui_start(:qt5) in your case

fixes the problem. I haven't figured out what is going on.

Could you let me know how did you debug it

At this point I think you need to debug PyCall.pygui_start (or qt_eventloop in your case) or something.

@KestutisMa
Copy link

It is working for me, just add show() at end.
I also modified first line runtests.jl of PyPlot to ENV["MPLBACKEND"]="qt"

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