nikhil kumar
nikhil kumar

Reputation: 55

How can I transfer file from SFTP using python 3.6

I would like to use paramiko for SFTP file transfer in Python 3.6. I know that paramiko depends on PyCrypto and have read about PyCrypto installation problems in Python 3.6. Although I have seen a number of questions regarding this topic, I have not found a solution to successful SFTP file transfer in Python 3.6.

My first question: is it possible to use Python 3.6 for SFTP file transfer? If so, will paramiko work? If the above will work, why I am I receiving the following errors when attempting to install PyCrypto?

error: [WinError 2] The system canot find the file specified
**Failed building wheel for pycrypto**

My second question: if paramiko will not work with Python 3.6, are there any alternatives or must I revert back to a previous python version for SFTP file transfer?

Upvotes: 1

Views: 3667

Answers (1)

Shariful Islam
Shariful Islam

Reputation: 576

Yes through python can possible to file transfer with sftp. Python has a nice package

Step 1 :

pip install pysftp

Step 2:

Example how to transfer file:

import pysftp

with pysftp.Connection('hostname', username='me', password='secret') as sftp:
    with sftp.cd('public'):             # temporarily chdir to public
        sftp.put('/my/local/filename')  # upload file to public/ on remote
        sftp.get('remote_file')         # get a remote file

Upvotes: 1

Related Questions