IOError: [Errno 2] 没有这样的文件 - Paramiko put() [英] IOError: [Errno 2] No such file - Paramiko put()
问题描述
我使用 Paramiko 和 sftp.put(localFile) 通过 SFTP 上传文件, 远程文件)
.如果需要,我首先使用
I'm uploading a file via SFTP using Paramiko with sftp.put(localFile, remoteFile)
. I make the necessary directory first if needed with
makeCommand = 'mkdir -p "' + remotePath + '"'
ssh.exec_command(makeCommand)
这有时有效,但我偶尔会收到以下错误:
this was works sometimes but I'm occasionally getting the following error:
sftp.put(localFile, remoteFile)
File "build/bdist.macosx-10.8-intel/egg/paramiko/sftp_client.py", line 565, in put
File "build/bdist.macosx-10.8-intel/egg/paramiko/sftp_client.py", line 245, in open
File "build/bdist.macosx-10.8-intel/egg/paramiko/sftp_client.py", line 635, in _request
File "build/bdist.macosx-10.8-intel/egg/paramiko/sftp_client.py", line 682, in _read_response
File "build/bdist.macosx-10.8-intel/egg/paramiko/sftp_client.py", line 708, in _convert_status
IOError: [Errno 2] No such file
尽管本地文件确实存在(并且 localFile
是它的正确路径)并且远程路径已生成.有讨论 here 和 这里 关于类似的问题,但那里提出的观点都没有帮助我.我的服务器支持 df -hi
命令.有没有人对此有任何建议或可能的解决方案?
despite the fact that the local file definitely exists (and localFile
is the correct path to it) and the remote path is made.
There is discussion here and here on a similar problem but none of the points raised there have helped me. My server supports the df -hi
command.
Has anyone any advice on this or a possible solution?
编辑
根据以下建议,我尝试使用 sftp.chdir(remoteDirectory)
更改工作目录,但此调用产生了与上述完全相同的错误.因此,这似乎不仅仅是上传问题.有什么想法吗?
After suggestions below I tried changing the working directory with sftp.chdir(remoteDirectory)
but this call produced the exact same error as above. So it seems this isn't just an upload issue. Any ideas?
推荐答案
似乎是远程文件夹权限问题.尽管远程文件夹是在文件上传之前创建的,但似乎该文件夹的权限阻止了上传.
It seems to be a remote folder permission problem. Although the remote folder was made before the file was uploaded, it appears the permissions on the folder were preventing an upload.
问题与这个问题有关- 如果我在上传之前对要上传的文件夹设置了打开权限,则程序可以正常上传.虽然对于权限问题,我应该得到 IOError: [Errno 13] Permission denied
,因为我进行了更改,我没有遇到任何错误.
The problem is linked to this issue - if I set open permissions on the folder I'll be uploading to before I upload, the program can upload fine. Although for a permission issue I should be getting IOError: [Errno 13] Permission denied
, since I made the changes I haven't encountered any errors.
我不确定是服务器给 Paramiko 的响应是问题所在,还是 Paramiko 本身的错误导致 IOError: [Errno 2] No such file
而不是Errno 13
,但这似乎解决了问题.
I'm not sure if it's the response the server is giving Paramiko which is the issue, or a bug in Paramiko itself which is causing IOError: [Errno 2] No such file
instead of a Errno 13
, but this appears to have solved the problem.
这篇关于IOError: [Errno 2] 没有这样的文件 - Paramiko put()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!