# PyCall error, number of arguments in a ccall function

**URL:** https://discourse.julialang.org/t/pycall-error-number-of-arguments-in-a-ccall-function/73143
**Category:** General Usage
**Tags:** pycall
**Created:** [December 15, 2021, 1:17pm UTC](https://discourse.julialang.org/t/pycall-error-number-of-arguments-in-a-ccall-function/73143 "2021-12-15T13:17:03Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![xor0110](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/xor0110/32/7926_2.png) [@xor0110](https://discourse.julialang.org/u/xor0110)
#### Post date: [December 15, 2021, 1:17pm UTC](https://discourse.julialang.org/t/pycall-error-number-of-arguments-in-a-ccall-function/73143/1 "2021-12-15T13:17:03Z")

</div>

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?

```julia
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

```

---

<div class="post-metadata">

### Author: ![cjdoris](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cjdoris/32/213133_2.png) [@cjdoris](https://discourse.julialang.org/u/cjdoris)
#### Post date: [December 15, 2021, 2:28pm UTC](https://discourse.julialang.org/t/pycall-error-number-of-arguments-in-a-ccall-function/73143/2 "2021-12-15T14:28:17Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![xor0110](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/xor0110/32/7926_2.png) [@xor0110](https://discourse.julialang.org/u/xor0110)
#### Post date: [December 16, 2021, 2:18pm UTC](https://discourse.julialang.org/t/pycall-error-number-of-arguments-in-a-ccall-function/73143/3 "2021-12-16T14:18:56Z")

</div>

Thanks for the reassurance. 🙂 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.
