简体   繁体   English

Python无法创建文件错误[错误:183]

[英]Python Cannot create a file error [Error : 183]

I am using the following code to copy the contents of one directory to another directory (python) 我正在使用以下代码将一个目录的内容复制到另一目录(python)

shutil.copytree(sourceDirectory,destinationDirectory,symlinks=False,ignore=ignore_patterns(updatedList))

where 哪里

updatedList = , .config, .ico,*.log UpdatedList =,.config .ico,*。log

I am generating this updatedList on the fly (based on user inputs) However I keep getting the following error whenever I try to perform the copy operation as stated above. 我正在动态生成此updatedList(基于用户输入),但是,每当尝试执行如上所述的复制操作时,都会不断出现以下错误。

[Error 183] Cannot create a file when that file already exists [错误183]该文件已存在时无法创建该文件

Note : There will be some files that are present in the source directory matching the extensions mentioned in the updatedList. 注意:源目录中将存在一些文件,这些文件与updatedList中提到的扩展名匹配。

I am thinking that mentioning the extension of the files that are already present in the ignore list should suffice, but apparently it does not. 我认为提及忽略列表中已经存在的文件扩展名就足够了,但是显然不是。

I am currently using Python 2.7 我目前正在使用Python 2.7

My Imports 我的进口

import logging
import os
from win32api import GetFileVersionInfo, LOWORD, HIWORD
import zipfile
import shutil
import sys
from os.path import isfile
from distutils import dir_util
import ConfigDTO
import datetime
import UpdateSettings
import time
import win32api
import socket
from shutil import copytree, ignore_patterns
import os

Please help . 请帮忙 。

Thanks 谢谢

I get it .. sorry it was my mistake. 我明白了..对不起,这是我的错误。 The document for shutil specifically says that the destination directory must not exist. 用于shutil的文档特别指出目标目录必须不存在。 well in my case , the destination directory was existing earlier and hence i was getting the message. 在我的情况下,目标目录早已存在,因此我收到了消息。

Thanks 谢谢

more information here 更多信息在这里

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 重命名txt文件。 编辑版本:[错误183]该文件已存在时无法创建该文件 - Rename txt file. Edited version: [Error 183] Cannot create a file when that file already exists 为什么我收到错误消息:“FileExistsError: [WinError 183] 当文件已存在时无法创建文件”? - Why am I getting the error: "FileExistsError: [WinError 183] Cannot create a file when that file already exists"? FileExistsError:[WinError 183] 当文件已存在时无法创建文件 - FileExistsError: [WinError 183] Cannot create a file when that file already exists Winerror 183 文件已存在时无法创建文件 - Winerror 183 Cannot create a file when that file already exists 使用 python os.rename 时报错【183】 - Error [183] when using python os.rename 错误元素在点 (183, 798) 处不可点击 - error Element is not clickable at point (183, 798) web scraping python selenium 如何解决 FileExistsError: [WinError 183] 当文件已经存在时无法创建文件? - How to resolve FileExistsError: [WinError 183] Cannot create a file when that file already exists? Python 创建目录错误 当文件已存在时无法创建文件 - Python create directory error Cannot create a file when that file already exists Python创建exe文件错误 - Python create exe file error Selenium Python中的错误-无法创建WebDriver - Error in Selenium Python - Cannot create webdriver
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM