Ik heb een vraag over het volgende script in Tutorial 4-1 van het Esri Gevorderde Gids voor Python boek: wanneer ik het uitvoer, geeft het een "FileExistsError"; het script maakt inderdaad een nieuwe map en een duplicaat .gdb-bestand aan, maar ik weet niet waarom. Hieronder staat het betreffende gedeelte met de daaropvolgende foutmelding. Bedankt!<\/P>
source_fgdb_path = Path(r".\Parking_Violations_and_Neighborhoods.gdb")<\/P>
arcpy.management.Compact(str(source_fgdb_path))<\/P>
# De naam van de map waarin de file geodatabase geplaatst wordt
fgdb_folder_name = source_fgdb_path.stem
# De locatie van de map waarin de file geodatabase geplaatst wordt
fgdb_folder_location = source_fgdb_path.parent
# Het pad naar de map waarin de file geodatabase geplaatst wordt
fgdb_folder_path = fgdb_folder_location.joinpath(fgdb_folder_name)
# Het pad van onze gekopieerde file geodatabase
fgdb_path = fgdb_folder_path.joinpath(source_fgdb_path.name)<\/P>
# Kopieer de file geodatabase naar de nieuwe locatie
shutil.copytree(source_fgdb_path, fgdb_path)
# Zip de file geodatabase
zipped_fgdb = shutil.make_archive(
base_name=fgdb_folder_path,
# De naam van het archief, exclusief de bestandsextensie
format="zip", # Het archiefformaat
root_dir=fgdb_folder_path, # De directory om te archiveren
)<\/P>
---------------------------------------------------------------------------<\/SPAN>
FileExistsError<\/SPAN> Traceback (most recent call last)
Cell In[7], line 2<\/SPAN>
1<\/SPAN> # Kopieer de file geodatabase naar de nieuwe locatie<\/SPAN>
----> 2<\/SPAN> shutil.<\/SPAN>copytree(source_fgdb_path, fgdb_path)
3<\/SPAN> # Zip de file geodatabase<\/SPAN>
4<\/SPAN> zipped_fgdb =<\/SPAN> shutil.<\/SPAN>make_archive(
5<\/SPAN> base_name=<\/SPAN>fgdb_folder_path,
6<\/SPAN> # De naam van het archief, exclusief de bestandsextensie<\/SPAN>
7<\/SPAN> format="zip", # Het archiefformaat<\/SPAN>
8<\/SPAN> root_dir=<\/SPAN>fgdb_folder_path, # De directory om te archiveren<\/SPAN>
9<\/SPAN> )
File ~\AppData\Local\Programs\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\Lib\shutil.py:573<\/SPAN>, in copytree(src, dst, symlinks, ignore, copy_function, ignore_dangling_symlinks, dirs_exist_ok)
571 with os.scandir(src) as itr:
572 entries = list(itr)
--> 573 return _copytree(entries=entries, src=src, dst=dst, symlinks=symlinks,
574 ignore=ignore, copy_function=copy_function,
575 ignore_dangling_symlinks=ignore_dangling_symlinks,
576 dirs_exist_ok=dirs_exist_ok)
File ~\AppData\Local\Programs\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\Lib\shutil.py:471, in _copytree(entries, src, dst, symlinks, ignore, copy_function, ignore_dangling_symlinks, dirs_exist_ok)
468 else:
469 ignored_names = ()
--> 471 os.makedirs(dst, exist_ok=dirs_exist_ok)
472 errors = []
473 use_srcentry = copy_function is copy2 or copy_function is copy
File <frozen os>:225, in makedirs(name, mode, exist_ok)
FileExistsError: [WinError 183]
<\/P>