python sftp transfer files always report that the file does not exist _paramiko SFTP upload file report raise IOError(text) OSError: Failure solution...

Due to work requirements, the paramiko module needs to be used to upload files to the server, but the following error is encountered during upload:

Traceback (most recent call last):

File "sf.py", line 10, in

sftp.put('/tmp/ttt.txt', '/tmp')

File "/usr/local/python3.5.2/lib/python3.5/site-packages/paramiko/sftp_client.py", line 727, in put

return self.putfo(fl, remotepath, file_size, callback, confirm)

File "/usr/local/python3.5.2/lib/python3.5/site-packages/paramiko/sftp_client.py", line 683, in putfo

with self.file(remotepath, 'wb') as fr:

File "/usr/local/python3.5.2/lib/python3.5/site-packages/paramiko/sftp_client.py", line 341, in open

t, msg = self._request(CMD_OPEN, filename, imode, attrblock)

File "/usr/local/python3.5.2/lib/python3.5/site-packages/paramiko/sftp_client.py", line 780, in _request

return self._read_response(num)

File "/usr/local/python3.5.2/lib/python3.5/site-packages/paramiko/sftp_client.py", line 832, in _read_response

self._convert_status(msg)

File "/usr/local/python3.5.2/lib/python3.5/site-packages/paramiko/sftp_client.py", line 865, in _convert_status

raise IOError(text)

After just checking, it was found that the path was not written as an absolute path when put, just use the OS module

sftp.put('/tmp/ttt.txt', os.path.join('/tmp', 'ttt.txt'))

Related: python sftp transfer files always report that the file does not exist _paramiko SFTP upload file report raise IOError(text) OSError: Failure solution...