JuliaPy / PyPlot.jl

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

plot() doesn't work with PyCall master #421

Closed PallHaraldsson closed 5 years ago

PallHaraldsson commented 5 years ago

https://github.com/JuliaPy/PyCall.jl/issues/636#issue-402719961

I thought I should let you know here too. I'm not sure if this is only a problem for PyPlot, or more (similar packages). At least it took me a long time to figure this out, so I thought best to let know here.

tkf commented 5 years ago

You can try my PR #420 with ]add PyPlot#remotes/cache/pull/420/head.

PallHaraldsson commented 5 years ago

@tkf Great!

With your PR this works. But shouldn't it have also worked without? I mean PyCall should be upwards compatible (PyPlot needing no changes?).

FYI: what happened without your your PR (different from before when only no plot displayed) an I assume more recent PyCall master:

julia> using PyPlot ERROR: InitError: type PyObject has no field version Stacktrace: [1] getproperty(::Any, ::Symbol) at ./sysimg.jl:18 [2] init() at /home/qwerty/.julia/packages/PyPlot/lLujW/src/init.jl:175 [3] _include_from_serialized(::String, ::Array{Any,1}) at ./loading.jl:633 [4] _require_search_from_serialized(::Base.PkgId, ::String) at ./loading.jl:713 [5] _require(::Base.PkgId) at ./loading.jl:937 [6] require(::Base.PkgId) at ./loading.jl:858 [7] require(::Module, ::Symbol) at ./loading.jl:853 during initialization of module PyPlot

julia> plot() ERROR: UndefVarError: plot not defined Stacktrace: [1] top-level scope at none:0

julia> using PyPlot

julia> plot() ERROR: MethodError: no method matching hasproperty(::PyCall.PyObject, ::String) Closest candidates are: hasproperty(::ColorMap, ::Union{AbstractString, Symbol}) at /home/qwerty/.julia/packages/PyPlot/lLujW/src/colormaps.jl:30 Stacktrace: [1] #plot#85(::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}, ::Function) at /home/qwerty/.julia/packages/PyPlot/lLujW/src/PyPlot.jl:186 [2] plot() at /home/qwerty/.julia/packages/PyPlot/lLujW/src/PyPlot.jl:186 [3] top-level scope at none:0

PallHaraldsson commented 5 years ago

This doesn't works on current PyCall master with latest PyPlot (while I only get warnings no plot displayed, this one may be the most important one: "Warning: No working GUI backend found for matplotlib"?):

julia> using PyPlot [ Info: Recompiling stale cache file /home/qwerty/.julia/compiled/v1.2/PyPlot/oatAj.ji for PyPlot [d330b81b-6aea-500a-939a-2ce795aea3ee] ┌ Warning: getindex(o::PyObject, s::Symbol) is deprecated in favor of dot overloading (getproperty) so elements should now be accessed as e.g. o.s instead of o[:s]. │ caller = init() at init.jl:175 └ @ PyPlot ~/.julia/packages/PyPlot/mQXSC/src/init.jl:175 ┌ Warning: getindex(o::PyObject, s::AbstractString) is deprecated in favor of dot overloading (getproperty) so elements should now be accessed as e.g. o."s" instead of o["s"]. │ caller = find_backend(::PyCall.PyObject) at init.jl:73 └ @ PyPlot ~/.julia/packages/PyPlot/mQXSC/src/init.jl:73 [..] ┌ Warning: getindex(o::PyObject, s::AbstractString) is deprecated in favor of dot overloading (getproperty) so elements should now be accessed as e.g. o."s" instead of o["s"]. │ caller = find_backend(::PyCall.PyObject) at init.jl:129 └ @ PyPlot ~/.julia/packages/PyPlot/mQXSC/src/init.jl:129 ┌ Warning: No working GUI backend found for matplotlib └ @ PyPlot ~/.julia/packages/PyPlot/mQXSC/src/init.jl:160 [..]

┌ Warning: setindex!(o::PyObject, v, s::Union{Symbol, AbstractString}) is deprecated in favor of setproperty!(o, s, v). │ caller = init() at init.jl:194 └ @ PyPlot ~/.julia/packages/PyPlot/mQXSC/src/init.jl:194 ┌ Warning: setindex!(o::PyObject, v, s::Union{Symbol, AbstractString}) is deprecated in favor of setproperty!(o, s, v). │ caller = init() at init.jl:195 └ @ PyPlot ~/.julia/packages/PyPlot/mQXSC/src/init.jl:195 [..]

julia> plot() ┌ Warning: haskey(o::PyObject, s::Union{Symbol, AbstractString}) is deprecated, use hasproperty(o, s) instead. │ caller = #plot#85(::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}, ::Function) at PyPlot.jl:176 └ @ PyPlot ~/.julia/packages/PyPlot/mQXSC/src/PyPlot.jl:176 ┌ Warning: getindex(o::PyObject, s::AbstractString) is deprecated in favor of dot overloading (getproperty) so elements should now be accessed as e.g. o."s" instead of o["s"]. │ caller = #plot#85(::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}, ::Function) at PyPlot.jl:179 └ @ PyPlot ~/.julia/packages/PyPlot/mQXSC/src/PyPlot.jl:179 0-element Array{Any,1}

(v1.2) pkg> status Status ~/.julia/environments/v1.2/Project.toml [54eb57ff] InteractiveCodeSearch v0.3.0 [438e738f] PyCall v1.18.5+ #master (https://github.com/JuliaPy/PyCall.jl.git) [d330b81b] PyPlot v2.7.0 [bf110322] Python v0.1.0 #master (https://github.com/229668880/Python.jl.git) [e6cf234a] RandomNumbers v1.0.3 [3646fa90] ScikitLearn v0.5.0

When not on PyCall's master this works, and confusingly it seems to have same git SHA commit. I'm not sure if it is the same.

stevengj commented 5 years ago

Closing in favor of JuliaPy/PyCall.jl#636 …