Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!eternal-september.org!feeder.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail From: Nobody Newsgroups: comp.lang.python Subject: Re: why can't download file from linux server into local window disk c:? Date: Mon, 08 Dec 2014 22:25:05 +0000 Organization: A noiseless patient Spider Lines: 21 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Injection-Info: mx02.eternal-september.org; posting-host="152d4dee6f95183c956ee6fa63d7e69f"; logging-data="32725"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+iZ+gx9rhbL/Omi7JyQ9F/" User-Agent: Pan/0.14.2 (This is not a psychotic episode. It's a cleansing moment of clarity.) Cancel-Lock: sha1:NN5lAdOhXSxpUO9+EFuu4yk6Vr8= Xref: csiph.com comp.lang.python:82150 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).