随笔 - 321  文章 - 0  评论 - 6  阅读 - 34万

paramiko put方法调用时提示IOError: [Errno 2] No such file的几种可能

复制代码
class sftp_operation:
    def __init__(self, host,port,username,password):
        self.host=host
        self.port=port
        self.username=username
        self.password=password
        transport = paramiko.Transport((self.host, self.port))
        transport.connect(username=self.username, password=self.password)
        self.sftp = paramiko.SFTPClient.from_transport(transport)

    def close(self):
        self.sftp.close()


调用:

    sftp=sftp_operation(args_param['host'],args_param['port'],args_param['username'],args_param['password'])

        sftp.sftp.put(os.path.join(local_path, f), os.path.join(remote_code_path,f))
复制代码

 

 

可能一、

本地文件或者远程目录存在权限问题,检查权限

 

可能二、

本地文件或者远程目录用了“~/xxxx/xxxx”,注意paramiko无法将~识别为个人的home目录,所以会提示找不到

posted on   该用户很懒  阅读(631)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· SQL Server 2025 AI相关能力初探
· AI编程工具终极对决:字节Trae VS Cursor,谁才是开发者新宠?
· 开源Multi-agent AI智能体框架aevatar.ai,欢迎大家贡献代码
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

点击右上角即可分享
微信分享提示