Skip to content

PyCall Wrongly look for Matplotlib in Python 3.6 instead of Python in Conda in Julia #998

Closed
@glanzkaiser

Description

@glanzkaiser

Dear all,

I am having this issue,

already wrote a lot here: https://discourse.julialang.org/t/ijulia-and-pyplot-backend-problem-with-old-python-version/85216/9

I am guessing it is on PyCall that is making the wrong call for matplotlib. Maybe it is still looking at Python 3.6 in my main OS system, instead of look for matplotlib in my new conda environment that is necessary to run pyplot().

I have installed newest matplotlib under new conda environment called pyplot_env then activate Julia environment and try a simple pyplot() backend plot:

using Plots; pyplot();

xc = [0,0,1,1]
yc = [0,1,1,0]
zc = [1,1,2,2];

plot(xc,yc,zc,st=:surface,camera=(-30,30))

The warning still occurs:
**Warning: You are using Matplotlib 3.3.4, which is no longer
│ officialy supported by the Plots community. To ensure smooth Plots.jl
│ integration update your Matplotlib library to a version >= 3.4.0
**│ **
│ If you have used Conda.jl to install PyPlot (default installation),
│ upgrade your matplotlib via Conda.jl and rebuild the PyPlot.
**│ **
│ If you are not sure, here are the default instructions:
**│ **
│ In Julia REPL:
│ ** │ import Pkg; │ Pkg.add("Conda") │ import Conda │ Conda.update() │ Pkg.build("PyPlot") **│
│ **
└ @ Plots /home/browni/.julia/packages/Plots/SkUg1/src/backends/pyplot.jl:29

Then the error:

**Error showing value of type Plots.Plot{Plots.PyPlotBackend}:
ERROR: PyError ($(Expr(:escape, :(ccall(#= /home/browni/.julia/packages/PyCall/7a7w0/src/pyfncall.jl:43 =# @pysym(:PyObject_Call), PyPtr, (PyPtr, PyPtr, PyPtr), o, pyargsptr, kw))))) <class 'AttributeError'>
AttributeError("'Text' object has no property 'math_fontfamily'",)
File "/home/browni/.local/lib/python3.6/site-packages/matplotlib/colorbar.py", line 761, in set_label
self._set_label()
File "/home/browni/.local/lib/python3.6/site-packages/matplotlib/colorbar.py", line 731, in _set_label
self.ax.set_ylabel(self._label, **self._labelkw)
File "/home/browni/.local/lib/python3.6/site-packages/matplotlib/axes/_axes.py", line 300, in set_ylabel
return self.yaxis.set_label_text(ylabel, fontdict, **kwargs)
File "/home/browni/.local/lib/python3.6/site-packages/matplotlib/axis.py", line 1566, in set_label_text
self.label.update(kwargs)
File "/home/browni/.local/lib/python3.6/site-packages/matplotlib/text.py", line 179, in update
super().update(kwargs)
File "/home/browni/.local/lib/python3.6/site-packages/matplotlib/artist.py", line 996, in update
raise AttributeError(f"{type(self).name!r} object "

Stacktrace:
[1] pyerr_check
@ ~/.julia/packages/PyCall/7a7w0/src/exception.jl:62 [inlined]
[2] pyerr_check
@ ~/.julia/packages/PyCall/7a7w0/src/exception.jl:66 [inlined]
[3] _handle_error(msg::String)
@ PyCall ~/.julia/packages/PyCall/7a7w0/src/exception.jl:83
[4] macro expansion
@ ~/.julia/packages/PyCall/7a7w0/src/exception.jl:97 [inlined]
[5] #107
@ ~/.julia/packages/PyCall/7a7w0/src/pyfncall.jl:43 [inlined]
[6] disable_sigint
@ ./c.jl:458 [inlined]
[7] __pycall!
@ ~/.julia/packages/PyCall/7a7w0/src/pyfncall.jl:42 [inlined]
[8] _pycall!(ret::PyCall.PyObject, o::PyCall.PyObject, args::Tuple{String}, nargs::Int64, kw::PyCall.PyObject)
@ PyCall ~/.julia/packages/PyCall/7a7w0/src/pyfncall.jl:29
[9] pycall!(ret::PyCall.PyObject, o::PyCall.PyObject, args::Tuple{String}, kwargs::Base.Pairs{Symbol, Any, NTuple{4, Symbol}, NamedTuple{(:size, :family, :math_fontfamily, :color), Tuple{Int64, String, String, NTuple{4, FixedPointNumbers.N0f8}}}})
@ PyCall ~/.julia/packages/PyCall/7a7w0/src/pyfncall.jl:11
[10] #
#114
@ ~/.julia/packages/PyCall/7a7w0/src/pyfncall.jl:86 [inlined]
[11] _before_layout_calcs(plt::Plots.Plot{Plots.PyPlotBackend})
@ Plots ~/.julia/packages/Plots/SkUg1/src/backends/pyplot.jl:1155
[12] prepare_output(plt::Plots.Plot{Plots.PyPlotBackend})
@ Plots ~/.julia/packages/Plots/SkUg1/src/plot.jl:218
[13] display(#unused#::Plots.PlotsDisplay, plt::Plots.Plot{Plots.PyPlotBackend})
@ Plots ~/.julia/packages/Plots/SkUg1/src/output.jl:139
[14] display(x::Any)
@ Base.Multimedia ./multimedia.jl:328
[15] #invokelatest#2
@ ./essentials.jl:716 [inlined]
[16] invokelatest
@ ./essentials.jl:714 [inlined]
[17] print_response(errio::IO, response::Any, show_value::Bool, have_color::Bool, specialdisplay::Union{Nothing, AbstractDisplay})
@ REPL ~/julia-1.7.3/share/julia/stdlib/v1.7/REPL/src/REPL.jl:293
[18] (::REPL.var"#45#46"{REPL.LineEditREPL, Pair{Any, Bool}, Bool, Bool})(io::Any)
@ REPL ~/julia-1.7.3/share/julia/stdlib/v1.7/REPL/src/REPL.jl:277
[19] with_repl_linfo(f::Any, repl::REPL.LineEditREPL)
@ REPL ~/julia-1.7.3/share/julia/stdlib/v1.7/REPL/src/REPL.jl:510
[20] print_response(repl::REPL.AbstractREPL, response::Any, show_value::Bool, have_color::Bool)
@ REPL ~/julia-1.7.3/share/julia/stdlib/v1.7/REPL/src/REPL.jl:275
[21] (::REPL.var"#do_respond#66"{Bool, Bool, REPL.var"#77#87"{REPL.LineEditREPL, REPL.REPLHistoryProvider}, REPL.LineEditREPL, REPL.LineEdit.Prompt})(s::REPL.LineEdit.MIState, buf::Any, ok::Bool)
@ REPL ~/julia-1.7.3/share/julia/stdlib/v1.7/REPL/src/REPL.jl:846
[22] #invokelatest#2
@ ./essentials.jl:716 [inlined]
[23] invokelatest
@ ./essentials.jl:714 [inlined]
[24] run_interface(terminal::REPL.Terminals.TextTerminal, m::REPL.LineEdit.ModalInterface, s::REPL.LineEdit.MIState)
@ REPL.LineEdit ~/julia-1.7.3/share/julia/stdlib/v1.7/REPL/src/LineEdit.jl:2493
[25] run_frontend(repl::REPL.LineEditREPL, backend::REPL.REPLBackendRef)
@ REPL ~/julia-1.7.3/share/julia/stdlib/v1.7/REPL/src/REPL.jl:1232
[26] (::REPL.var"#49#54"{REPL.LineEditREPL, REPL.REPLBackendRef})()
@ REPL ./task.jl:429**

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions