PyCall error, number of arguments in a ccall function

I have a script that calls functions from the Python OpenCV module via PyCall. Everything was working fine the other day, not sure what changed in my configuration. I use PyCall with my system python at /usr/bin/python3. Just tried to re-build PyCall already. What could cause this?

ERROR: PyError ($(Expr(:escape, :(ccall(#= /home/user/.julia/packages/PyCall/3fwVL/src/pyfncall.jl:43 =# @pysym(:PyObject_Call), PyPtr, (PyPtr, PyPtr, PyPtr), o, pyargsptr, kw))))) <class 'TypeError'>
TypeError('function takes exactly 2 arguments (3 given)')

Stacktrace:
  [1] pyerr_check
    @ ~/.julia/packages/PyCall/3fwVL/src/exception.jl:62 [inlined]
  [2] pyerr_check
    @ ~/.julia/packages/PyCall/3fwVL/src/exception.jl:66 [inlined]
  [3] _handle_error(msg::String)
    @ PyCall ~/.julia/packages/PyCall/3fwVL/src/exception.jl:83
  [4] macro expansion
    @ ~/.julia/packages/PyCall/3fwVL/src/exception.jl:97 [inlined]
  [5] #107
    @ ~/.julia/packages/PyCall/3fwVL/src/pyfncall.jl:43 [inlined]
  [6] disable_sigint
    @ ./c.jl:458 [inlined]
  [7] __pycall!
    @ ~/.julia/packages/PyCall/3fwVL/src/pyfncall.jl:42 [inlined]
  [8] _pycall!(ret::PyObject, o::PyObject, args::Tuple{PyObject, PyObject, PyObject, PyObject, Tuple{Int64, Int64, Int64}, PyObject, PyObject}, nargs::Int64, kw::Ptr{Nothing})
    @ PyCall ~/.julia/packages/PyCall/3fwVL/src/pyfncall.jl:29
  [9] _pycall!(ret::PyObject, o::PyObject, args::Tuple{PyObject, PyObject, PyObject, PyObject, Tuple{Int64, Int64, Int64}, PyObject, PyObject}, kwargs::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
    @ PyCall ~/.julia/packages/PyCall/3fwVL/src/pyfncall.jl:11
 [10] (::PyObject)(::PyObject, ::Vararg{Any}; kwargs::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
    @ PyCall ~/.julia/packages/PyCall/3fwVL/src/pyfncall.jl:86
 [11] (::PyObject)(::PyObject, ::Vararg{Any})
    @ PyCall ~/.julia/packages/PyCall/3fwVL/src/pyfncall.jl:86
 [12] top-level scope

That’s an ordinary Python TypeError saying a function was called with the wrong number of arguments. You should be able to use standard Python debugging tools like pdb to figure out where the problem is.

Thanks for the reassurance. :slight_smile: Damn, that was cryptic. The problem is that one argument I was passing to a function with 7 parameters was a tuple that is supposed to have 2 elements, and I had 3 elements there! So it’s probably some implicit intermediary function call that was failing.