why can't download file from linux server into local window disk c:?

Nobody nobody at nowhere.invalid
Mon Dec 8 17:25:05 EST 2014


On Tue, 09 Dec 2014 00:14:15 -0800, pengsir wrote:

> localpath = 'c:'
> sftp.get(filepath, localpath)

>      with open(localpath, 'wb') as fl:
> PermissionError: [Errno 13] Permission denied: 'c:'

It's trying to open "c:", which is a drive, as if it was a file.

You have to specify the destination filename, not just the directory.

Also, you probably shouldn't be trying to write to the root directory of
the C drive. You should probably be using a directory beneath either
%USERPROFILE% or %ALLUSERSPROFILE%.

Writing to the root of the system drive tends to require Administrator
privileges. Even if the current user is an administrator, the process must
have elevated privilege (e.g. via "Run as Administrator" or an explicit
privilege-elevation request from within the code).




More information about the Python-list mailing list