Python tqdm TypeError: <lambda>() takes 1 positional argument but 2 were given

3.3k views Asked by At

I tried to create a progress bar to view progress of file transferring by using the below code.

from tqdm import tqdm
import pysftp
cnopts = pysftp.CnOpts()
cnopts.hostkeys = None
srv = pysftp.Connection(host=host,username=username,password=password,cnopts=cnopts)
with tqdm(unit = 'blocks', unit_scale = True, leave = False, miniters = 1, desc = 'Uploading......', total = filesize) as tqdm_instance:
    srv.put("D:\\wp-deploy.jpg","/var/www/html/wp-deploy.jpg",callback=lambda sent:tqdm_instance.update(len(sent)))

and I got this error:

TypeError: <lambda>() takes 1 positional argument but 2 were given
1

There are 1 answers

1
Ignacio Vazquez-Abrams On BEST ANSWER

From the docs:

  • callback (callable) – optional callback function (form: func(int, int)) that accepts the bytes transferred so far and the total bytes to be transferred