无法使用Shutil从远程计算机复制文件 [英] Cannot copy file from a remote machine using shutil

查看:170
本文介绍了无法使用Shutil从远程计算机复制文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要从远程计算机复制文件.

I need to copy a file from a remote machine.

代码是这样的

import shutil

shutil.copyfile('//XXX.XXX.XXX.XXX/home/Shares Folder/file.txt','/home/file.txt')

文件的位置是一个共享文件夹,但是每次我运行它都会给我这个错误

the location of the file is a shared folder but everytime I run this it gives me this error

文件",第1行,位于?

File "", line 1, in ?

在复制文件中,文件"usr/lib/python2.4/shutil.py",第47行

File "usr/lib/python2.4/shutil.py", line 47, in copyfile

frsc =打开(src,'rb')

frsc = open (src,'rb')

IOError:[错误2]没有这样的文件或目录:'//XXX.XXX.XXX.XXX/home/Shares Folder/file.txt'

IOError: [Errno 2] No such file or directory : '//XXX.XXX.XXX.XXX/home/Shares Folder/file.txt'

请注意,我正在当前计算机上运行此脚本,并且要复制的文件在远程计算机上.无论如何,我不确定这个细节是否有用.

Please take note that I'm running this script in my current machine and the the file that I want to copy is in the remote machine. I am not sure if this detail's relevant, I'm saying anyway.

我100%确定该文件在那里,所以我想知道为什么它会给我这样的错误消息.

Im 100% sure that the file is there so I was wondering why it's giving me such error message.

我使用CentOS和python 2.4.3

Im using CentOS and python 2.4.3

有什么想法吗?

推荐答案

shutil 不支持远程文件副本.它仅适用于本地副本.如果您的两台计算机都是基于UNIX的,则可以尝试使用一些模块进行可用的传输( SSH/SFTP rsync ,whonot)

shutil doesn't support remote file copies. It's for local copies only. If both of your machines are UNIX-based, you can try and employ some modules for a transport that you have available (SSH/SFTP, rsync, whanot)

这篇关于无法使用Shutil从远程计算机复制文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆