Error when running custom script tool

4582
13
05-20-2016 07:01 AM
SadanandacharB1
New Contributor III

Hi All

  I am getting error when running custom created script tool to copy feature classes from folder to geodatabase

below is the error

Traceback (most recent call last):
  File "D:\Python DVD\Python\Data\Exercise02\CopyFeature.py", line 9, in <module>
    arcpy.CopyFeatures_management(fc, os.path.join(outgdb, fcdesc.basename))
  File "c:\program files (x86)\arcgis\desktop10.2\arcpy\arcpy\management.py", line 2429, in CopyFeatures
    raise e
ExecuteError: ERROR 000210: Cannot create output E:\ArcPy\ResultFeatures\basin
Failed to execute (CopyFeatures).
Failed to execute (MyCopy).

What am i missing, Please help me

0 Kudos
13 Replies
DanPatterson_Retired
MVP Esteemed Contributor

and the script? the details are within

0 Kudos
BenjaminMittler
Occasional Contributor III

It doesn't look as if there is a geodatabase in your output file path, based on the error you are receiving.

curtvprice
MVP Esteemed Contributor

From what I can see Benjamin hit the nail on the head. Workspaces can be folders or geodatabases.

Your second tool parameter should be an existing geodatabase, that is "E:\ArcPy\ResultFeatures\Test1.gdb" (instead of a folder:  "E:\ArcPy\ResultFeatures"). 

You can set the parameter Filter property to exclude folders - this will prevent you from providing a folder name for the second argument by mistake. Also -- make sure this parameter is of type Input to make sure you provide the path to an existing geodatabase.

SadanandacharB1
New Contributor III

Thank you so much for your HELP

0 Kudos
AdrianWelsh
MVP Notable Contributor

Hi Sadanandachar,

Can you post the script?

0 Kudos
SadanandacharB1
New Contributor III

Hi below is my script created  for custom tool

import arcpy
import os
from arcpy import env
env.workspace = arcpy.GetParameterAsText(0)
outgdb = arcpy.GetParameterAsText(1)
fclist = arcpy.ListFeatureClasses()
for fc in fclist:
    fcdesc = arcpy.Describe(fc)
    arcpy.CopyFeatures_management(fc, os.path.join(outgdb, fcdesc.basename))
0 Kudos
DanPatterson_Retired
MVP Esteemed Contributor

You should keep these links handy

What is ArcPy?—Help | ArcGIS for Desktop

ArcInfo Workstation Item properties—Help | ArcGIS for Desktop

Describe object properties—Help | ArcGIS for Desktop

and particularly

env—Help | ArcGIS for Desktop with the overwriteOutput option.  Sometime a 'can't create... means that it already exists and can't be overwriten since env.overwriteOutput = True needs to be set

AdrianWelsh
MVP Notable Contributor

Oooh, that's a good one. Forgot about:

env.overwriteOutput = True

That may be the issue here.

0 Kudos
SadanandacharB1
New Contributor III

Thank you very much

0 Kudos