AnsweredAssumed Answered

Script won't run outside of ArcMap

Question asked by mikeri1000 on Nov 18, 2015
Latest reply on Nov 18, 2015 by mikeri1000

Hello, I am fairly new to Python, but I'm having an issue running a script. It runs fine when I use the python window in ArcMap, but when I try to run the same script either from double clicking a .py file, or running in the IDLE window, I get an error. I know I can easily do this just using select by attributes in ArcMap, but I'm trying to learn more python to automate more things down the road, this is a first test.

 

The Code:

import arcpy
import os

tree = r"M:\\Temp\ArcPy\Tree.shp"
arcpy.env.overwriteOutput=True 
arcpy.MakeFeatureLayer_management(tree, "Tree")
arcpy.SelectLayerByAttribute_management("Tree","NEW_SELECTION",' "Diameter" >=50')
arcpy.CopyFeatures_management ("Tree","Trees50DBH")
arcpy.FeatureClassToFeatureClass_conversion("TreesGreater50DBH",r"M:\\Temp\ArcPy","Tree50DBH")

 

The Error (happens at the arcpy.CopyFeatures_management code)

Traceback (most recent call last):

  File "M:\Temp\ArcPY\TreeArcPyTest.py", line 12, in <module>

    arcpy.CopyFeatures_management ("Tree","Trees50DBH")

  File "C:\Program Files (x86)\ArcGIS\Desktop10.3\ArcPy\arcpy\management.py", line 2434, in CopyFeatures

    raise e

ExecuteError: ERROR 000210: Cannot create output Trees50DBH

Failed to execute (CopyFeatures).

 

I tried searching the various solutions here and elsewhere, but largely they don't apply? Thanks for your help.

Outcomes