當我嘗試從遠程服務器獲取文件時,我遇到了paramiko的問題,它給了我IOError: [Errno 2] No such file
。這裏是我的代碼:Paramiko get()如果服務器不支持df -hi會引發IOError「No such file」
# set up a transport object t (using an rsa key), which connected successfully
>>> t.is_active()
True
>>> sftp = paramiko.SFTPClient.from_transport(t)
>>> files = sftp.listdir() # files holds the list ['canceled', 'downloaded', 'FILE.06222012.TXT']
>>> sftp.get(files[2], '.')
IOError: [Errno 2] No such file
然而,當我連接到SFTP發佈在命令行上(因爲我開了蟒蛇REPL相同的用戶),我可以獲取文件。有任何想法嗎?
編輯:我發現這個職位它好像我有https://bugs.launchpad.net/paramiko/+bug/492238在互動SFTP提示問題:
sftp> df -hi
Server does not support [email protected] extension
此錯誤是從2009年並沒有結束,(但我使用最新的paramiko 1.7.7.1)。任何人都知道解決方法?我可以強制paramiko只是做簡單的sftp get的等價物,而不嘗試檢查文件的完整性嗎?
不幸的是,這不起作用。 'open()'以及除listdir()之外的幾乎每種方法都會觸發相同的錯誤 – danny
它究竟在哪裏失敗?請發佈回溯。你確定失敗在'SFTPClient.stat()'中 – mhawke