PyPlot.jl icon indicating copy to clipboard operation
PyPlot.jl copied to clipboard

I get this error in Julia: ArgumentError: hasproperty of NULL PyObject What is it and how to resolve it?

Open aj002 opened this issue 4 years ago • 13 comments
trafficstars

ArgumentError: hasproperty of NULL PyObject

Stacktrace: [1] pyhasproperty(::PyCall.PyObject, ::String) at C:\Users\Home.julia\packages\PyCall\BcTLp\src\PyCall.jl:359 [2] hasproperty at C:\Users\Home.julia\packages\PyCall\BcTLp\src\PyCall.jl:365 [inlined] [3] ioff(; kws::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}) at C:\Users\Home.julia\packages\PyPlot\XHEG0\src\PyPlot.jl:174 [4] ioff() at C:\Users\Home.julia\packages\PyPlot\XHEG0\src\PyPlot.jl:174 [5] top-level scope at C:\Users\Home.julia\packages\Plots\vsE7b\src\backends.jl:510 [6] eval at .\boot.jl:331 [inlined] [7] _initialize_backend(::Plots.PyPlotBackend) at C:\Users\Home.julia\packages\Plots\vsE7b\src\backends.jl:504 [8] backend at C:\Users\Home.julia\packages\Plots\vsE7b\src\backends.jl:174 [inlined] [9] pyplot(; kw::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}) at C:\Users\Home.julia\packages\Plots\vsE7b\src\backends.jl:31 [10] pyplot() at C:\Users\Home.julia\packages\Plots\vsE7b\src\backends.jl:31 [11] top-level scope at In[10]:2 [12] include_string(::Function, ::Module, ::String, ::String) at .\loading.jl:1091

aj002 avatar Nov 22 '20 06:11 aj002

Having the same problem recently, though I'm running manjaro

isentropic avatar Nov 26 '20 04:11 isentropic

but I narrowed it to

julia> using PyPlot
┌ Warning: No working GUI backend found for matplotlib
└ @ PyPlot ~/.julia/packages/PyPlot/XHEG0/src/init.jl:165
ERROR: InitError: PyError (PyImport_ImportModule) <class 'ValueError'>
ValueError('call stack is not deep enough')
  File "/usr/lib/python3.8/site-packages/shiboken2/files.dir/shibokensupport/__feature__.py", line 107, in _import
    importing_module = sys._getframe(1).f_globals.get("__name__", "__main__")

isentropic avatar Nov 26 '20 04:11 isentropic

Native python works of course, but also:

julia> plt = pyimport("matplotlib.pyplot")
PyObject <module 'matplotlib.pyplot' from '/home/zhanibek/.local/lib/python3.8/site-packages/matplotlib/pyplot.py'>

julia> plt.plot(1)
1-element Array{PyObject,1}:
 PyObject <matplotlib.lines.Line2D object at 0x7f268cba9370>

julia> plt.show()

works too. I tried using sytem python and rebuilding both packages to no avail. This happened after a recent system update

isentropic avatar Nov 26 '20 04:11 isentropic

i also got his bug, seems pyplot is very hard to use. We cannot even find a solution for this bug.

zhaoguangyuan123 avatar Nov 18 '21 07:11 zhaoguangyuan123

i also got his bug, seems pyplot is very hard to use. We cannot even find a solution for this bug.

I am experiencing the same problem...

arghavanpartovifard avatar Nov 26 '21 14:11 arghavanpartovifard

Same here

gideonsimpson avatar Dec 16 '21 03:12 gideonsimpson

Hi, I also ran into this issue. In my case i called

scatter(...)
scatter!(...)

inside a loop. adding the overwrite_figure=true argument to scatter(...) resolved it for me.

bennib22 avatar Mar 31 '22 14:03 bennib22

Same problem, did you solve it?

czy20000902 avatar Jan 22 '24 22:01 czy20000902

It generally means that PyPlot wasn't able to initialize properly — there was probably an error earlier that you ignored?

stevengj avatar Jan 22 '24 23:01 stevengj