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).

  • Please edit the question in response to requests for clarification or answers that don't solve your issue. You have a glaring naming bug (failure to use double-backslash or the raw formatting prefix (r"C:\foo") but it seems there are multiple issues, so you should update your code.
    – Vince
    Jan 5 '18 at 10:51

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.

  • I added workspace to the code, still having the problem.
    – bug
    Jan 5 '18 at 9:28
  • Are you sure the workspace exists?
    – GISGe
    Jan 5 '18 at 9:29

You need to deal with the backslash which has special meaning to Python. I recommend using an r to treat it as a raw string.

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

should be:

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.