import arcpy from arcpy import env arcpy.env.overwriteOutput = True arcpy.CopyFeatures_management("U:\GIS_Data\Geodatabase\TEST_2.mdb\lines\other_line", "U:\TEST_2.gdb\lines\other_line")
Runtime error Traceback (most recent call last): File "<string>", line 1, in <module> File "C:\Program Files (x86)\ArcGIS\Desktop10.1\arcpy\arcpy\management.py", line 2227, in CopyFeatures raise e ExecuteError: Failed to execute. Parameters are not valid. ERROR 000732: Input Features: Dataset U:\GIS_Data\Geodatabase\TEST_2.mdb\lines\other_line does not exist or is not supported WARNING 000725: Output Feature Class: Dataset U:\TEST_2.gdb\lines\other_line already exists. Failed to execute (CopyFeatures).
Solved! Go to Solution.
# double backslash line = "U:\\GIS_Data\\Geodatabase\\TEST_2.mdb\\lines\\other_line" # raw string (easiest method) line = r"U:\GIS_Data\Geodatabase\TEST_2.mdb\lines\other_line" # forward slash line = "U:/GIS_Data/Geodatabase/TEST_2.mdb/lines/other_line"
import arcpy arcpy.env.overwriteOutput = True # variables original = r"U:\GIS_Data\Geodatabase\TEST_2.mdb\lines\other_line" copy = r"U:\TEST_2.gdb\lines\other_line" # explicitly delete output if it exists if arcpy.Exists(copy): arcpy.Delete_management(copy) # copy features tool arcpy.CopyFeatures_management(original, copy)
>>> test = 'C:\Data\new_folder\tables\Schools.dbf' >>> print test C:\Data ew_folder ables\Schools.dbf >>> test = r'C:\Data\new_folder\tables\Schools.dbf' >>> print test C:\Data\new_folder\tables\Schools.dbf >>>
# double backslash line = "U:\\GIS_Data\\Geodatabase\\TEST_2.mdb\\lines\\other_line" # raw string (easiest method) line = r"U:\GIS_Data\Geodatabase\TEST_2.mdb\lines\other_line" # forward slash line = "U:/GIS_Data/Geodatabase/TEST_2.mdb/lines/other_line"
import arcpy arcpy.env.overwriteOutput = True # variables original = r"U:\GIS_Data\Geodatabase\TEST_2.mdb\lines\other_line" copy = r"U:\TEST_2.gdb\lines\other_line" # explicitly delete output if it exists if arcpy.Exists(copy): arcpy.Delete_management(copy) # copy features tool arcpy.CopyFeatures_management(original, copy)
>>> test = 'C:\Data\new_folder\tables\Schools.dbf' >>> print test C:\Data ew_folder ables\Schools.dbf >>> test = r'C:\Data\new_folder\tables\Schools.dbf' >>> print test C:\Data\new_folder\tables\Schools.dbf >>>
When using Python, a single backslash is known as an escape character.
When using Python, a single backslash is known as an escape character. Therefore, to use a backslash you must use a double backslash or use the raw string method. So for your paths you can supply them one of 3 ways:
# double backslash line = "U:\\GIS_Data\\Geodatabase\\TEST_2.mdb\\lines\\other_line" # raw string (easiest method) line = r"U:\GIS_Data\Geodatabase\TEST_2.mdb\lines\other_line" # forward slash line = "U:/GIS_Data/Geodatabase/TEST_2.mdb/lines/other_line"
The second option is the easiest in my opinion. Try changing your code to:
import arcpy arcpy.env.overwriteOutput = True # variables original = r"U:\GIS_Data\Geodatabase\TEST_2.mdb\lines\other_line" copy = r"U:\TEST_2.gdb\lines\other_line" # explicitly delete output if it exists if arcpy.Exists(copy): arcpy.Delete_management(copy) # copy features tool arcpy.CopyFeatures_management(original, copy)
Here is a quick example to show you how some escape characters work. The '\n' is the new line character, and the '\t' is a tab.
>>> test = 'C:\Data\new_folder\tables\Schools.dbf' >>> print test C:\Data ew_folder ables\Schools.dbf >>> test = r'C:\Data\new_folder\tables\Schools.dbf' >>> print test C:\Data\new_folder\tables\Schools.dbf >>>
Also, I just took another look at your error messages...Did you install the 64 bit background processing? If so, your Python may be defaulting to the 64 bit Python version, which does not support Personal geodatabases. Otherwise, you could try explicitly deleting the output if it exists.
EDIT: Didn't read the bottom of you post.......I am running 10.1 with SP1 and did switch to the 64 bit processing. It's always something
start C:\Python27\ArcGIS10.1\python.exe G:\PROJECTS\Cedar\GeneralScripts\PyLibrary\FormattedExcel.py
import sys print sys.version
2.7.3 (default, Apr 10 2012, 23:24:47) [MSC v.1500 64 bit (AMD64)]
2.7.3 (default, Apr 10 2012, 23:31:26) [MSC v.1500 32 bit (Intel)]