调试& 可能的原因是 distutils.dir_util.copy_tree()不存在或不是常规文件。

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

我有一些简单的代码来导入Windows文件路径的csv文件,例如:将内容和任何子文件夹复制到新的目录。"C:/Folder/SubFolder/folder1" 复制内容和任何子文件夹到一个新的目录。

当我运行这段代码时,我的样本中大约有13个返回了 doesn't exist or not a regular file 而其他的都复制成功了。

引起问题的文件不是.docx就是.pdf,但同样有很多文件被成功复制过来。

是什么原因导致了本地Windows 10机器上的这个问题,我如何进一步调试?

for Submission in FilePaths.itertuples():
    Create the Path
    FolderName = Submission.Group+"-"+Submission.ID+"-"+Submission.FirstName+Submission.Surname
    DestinationPath =DestinationBasePath + Submission.Category+"\\"+ Submission.Value+"\\"+FolderName
    #Copy the source folder tree and contents to the destination 
    try:
        copy_tree(Submission.FullFilePath, DestinationPath,verbose=1)
    except Exception as Ex:
    print(Ex)
    os.listdir(Submission.FullFilePath)
python-3.x distutils copytree
1个回答
0
投票

我怀疑这与同步或文件锁定问题有关,这使得文件无法被复制。

© www.soinside.com 2019 - 2024. All rights reserved.