我试图理解为什么我在使用paramiko 1.7.6时出现“Permission Denied”错误

时间:2011-05-01 16:54:51

标签: python windows paramiko

任何人都可以告诉我为什么我收到以下错误:

Traceback (most recent call last):
  File "C:\Python27\connect.py", line 22, in <module>
    sftp.get(filepath, localpath)
  File "C:\Python27\lib\site-packages\paramiko-1.7.6-py2.7.egg\paramiko\sftp_client.py", line 603, in get
    fl = file(localpath, 'wb')
IOError: [Errno 13] Permission denied: 'C:\\remote'

我在Windows 7(管理员)计算机上使用Python 2.7登录到Ubuntu 10.10计算机。这是我正在使用的非常简单的脚本:

import paramiko
import os




paramiko.util.log_to_file('c:\Python27\paramiko-wininst.log')

host = '192.168.1.14'
port = 22
transport = paramiko.Transport((host,port))
password = 'xxxxxx'
username = 'username'
transport.connect(username = username, password = password)

sftp = paramiko.SFTPClient.from_transport(transport)



filepath = '/home/my.log'
localpath = 'C:\\remote'
sftp.get(filepath, localpath)


sftp.close()
transport.close()

1 个答案:

答案 0 :(得分:4)

尝试进行以下更改

localpath = 'C:\\remote'
sftp.get(filepath, localpath)

将其修改为

localpath = 'C:\remote\my.log'
sftp.get(filepath, localpath)