-
Got the following error, what could be the problem?
or use julia array: Thank you! |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 3 replies
-
I think this usually happens when trying to do a py->jl conversion that is not supported. For example: julia> using PythonCall
julia> Float64[pyfloat(4)]
ERROR: MethodError: Cannot `convert` an object of type Py to an object of type Float64
Closest candidates are:
convert(::Type{T}, ::T) where T<:Number at ~/julia-1.7.2/share/julia/base/number.jl:6
convert(::Type{T}, ::Number) where T<:Number at ~/julia-1.7.2/share/julia/base/number.jl:7
convert(::Type{T}, ::Base.TwicePrecision) where T<:Number at ~/julia-1.7.2/share/julia/base/twiceprecision.jl:262
...
Stacktrace:
[1] setindex!(A::Vector{Float64}, x::Py, i1::Int64)
@ Base ./array.jl:903
[2] getindex(#unused#::Type{Float64}, x::Py)
@ Base ./array.jl:412
[3] top-level scope
@ REPL[2]:1 So I think a Julia object might be sneaking into your setup somewhere before it is passed to a python function that does not know how to handle it.
Same thing here. |
Beta Was this translation helpful? Give feedback.
-
This is amazing! Thank you very much for your help! |
Beta Was this translation helpful? Give feedback.
-
Your first error was on line 8, the one below the one highlighted, namely |
Beta Was this translation helpful? Give feedback.
Your first error was on line 8, the one below the one highlighted, namely
fps[i] = arr
, which is complaining that you're trying to set an element of an array of floats to a Python object.