[GIS] ERROR 000210 Cannot create output ‘name’ Failed to execute CopyFeatures

arcgis-desktoparcpyerror-000210

I'm learning ArcPy, when I run this code from Python on ArcMap it works. But it does not work from the separate Python shell.

import arcpy
from arcpy import env
import os
output_dir = "C:/Data"
env.workspace = os.path.join(output_dir, "Output.gdb")
env.overwriteOutput = True   

output_features = "name"
origins = "C:\Users\username\AppData\Roaming\ESRI\Desktop10.5\ArcCatalog\Connection to sde.sde\SDE.tablename" 

arcpy.management.CopyFeatures(origins, output_features)

I'm getting arcgisscripting.ExecuteError: ERROR 000210: Cannot create output 'name' Failed to execute (CopyFeatures).

Best Answer

You haven't defined a workspace for your output, just a basename. If you run your script in ArcGIS, arcpy will use the default workspace defined at the application level. But this won't work outside ArcGIS. Either

  • use arcpy.env.workspace (e.g. arcpy.env.workspace = r"C:\Data\gdb.gdb) in the beginning of your script to set the workspace,
  • or set the full path to your output (e.g. output_features = r"C:\Data\gdb.gdb\name")

Note that the workspace (folder or gdb) must exist, it won't be created by Copy Features.

Related Question