marcelorodrigues
marcelorodrigues

Reputation: 1039

how to do sftp python 3?

I am using the code below to do sftp: #!/opt/python3/bin/python3

import paramiko
import sys
host = '192.168.1.2'
port = 22622
transport = paramiko.Transport((host, port))
password = "p@ssw0rd"
username = "web"
transport.connect(username = username, password = password)
sftp = paramiko.SFTPClient.from_transport(transport)
path = '/log/ERROR.LOG'
localpath = '/home/web/ERROR.LOG'
sftp.get(path, localpath)
sftp.close()
transport.close()
print ("Download done.")

But the output is:

Traceback (most recent call last):
File "c.py", line 2, in <module>
import paramiko
ImportError: No module named paramiko

Is there no Paramiko module for Python3?

What do I have to use to do sftp?

Upvotes: 3

Views: 2228

Answers (1)

steveha
steveha

Reputation: 76765

Paramiko does not yet officially support Python 3. I found a bug discussing it, and SFTP is one of the problem spots:

https://github.com/paramiko/paramiko/issues/16

I recommend using subprocess to run the sftp command-line tool.

Upvotes: 1

Related Questions