FileNotFoundError:将excel文件推送到sftp服务器时

问题描述 投票:0回答:1

我一直试图从Windows本地系统通过python将excel文件推送到sftp服务器。

下面是我尝试过的代码。

import pandas as pd
import paramiko
sftpURL   =  '100.35.1.16'
sftpUser  =  'xyz'
sftpPass  =  'user@123'

ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy( paramiko.AutoAddPolicy())
ssh.connect(sftpURL, username=sftpUser, password=sftpPass,port=6381)
ftp = ssh.open_sftp()
localPath = "D:/folder/myfolder/abc.xlsx"
sftpPath = "/home/var/reports/abc.xlsx"
files = ftp.put(sftpPath,localPath)

执行此操作后,我在下面看到此错误

FileNotFoundError: [WinError 3] The system cannot find the path specified: '/home/var/reports/abc.xlsx'

我能够通过Filezilla连接到sftp服务器,当我通过Python代码列出目录时也成功,但是当通过Python将文件推送到相同位置时,我遇到了这个问题。

我也在线尝试了大多数研究,也使用了pysftp包,但没有运气。

我不确定我要去哪里错了。请提出建议。

python python-3.x file-not-found
1个回答
0
投票

put() method的签名是:

put()

看来您已经颠倒了论点。将您的看跌期权更改为:

put(localpath, remotepath, callback=None, confirm=True)
© www.soinside.com 2019 - 2024. All rights reserved.