Rakesh Nittur
Rakesh Nittur

Reputation: 475

"put() takes at least 3 arguments (2 given)" when calling Paramiko sftp.put

I want to copy a text file from my local machine onto a remote server using SCP/SFTP. I already have an established an SSH channel between the source and destination.

sftp.put('sourcepath, destinationpath')

Above command gives an error:

TypeError: put() takes at least 3 arguments (2 given)

Upvotes: 0

Views: 1254

Answers (1)

Martin Prikryl
Martin Prikryl

Reputation: 202340

That's rather a question on Python than Paramiko.

You have the syntax for passing the arguments wrong.

The put method is defined as

def put(self, localpath, remotepath, callback=None, confirm=True):

A call should be like:

sftp.put('sourcepath', 'destinationpath')

With your syntax, you are passing one string argument (to localpath) with a comma inside the string value.

The Python error message is bit confusing, because it counts even the implicit self argument. So you have provided a value to 2 parameters, self (implicitly by sftp.) and localpath (explicitly by 'sourcepath, destinationpath'). You are missing the 3rd mandatory parameter, the remotepath. The other parameters are optional.

Upvotes: 1

Related Questions