Python Copy_management throws exception "ERROR 000979"

4825
3
10-05-2010 08:21 AM
NeilRipley
New Contributor
I am trying to copy a series of feature classes from a file geodatabase out to a folder of shapefiles but am encountering a problem.

The code below is throwing this exception:
Failed to execute. Parameters are not valid.
ERROR 000979: Cannot copy between different workspaces.
Failed to execute (Copy).

Any help would be appreciated.

import arcpy, sys, os, string

infc = r'C:\temp\basedata\SK_BS.gdb\BS_1250009_0'
outshp = r'C:\temp\Basedata_shps\BS_1250009_0.shp'

outpath = r'C:\temp\Basedata_shps'

arcpy.env.workspace = outpath
arcpy.Copy_management(infc, outshp)
0 Kudos
3 Replies
ChrisSnyder
Regular Contributor III
Try either this:

import arcpy, sys, os, string
infc = r'C:\temp\basedata\SK_BS.gdb\BS_1250009_0'
outshp = r'C:\temp\Basedata_shps\BS_1250009_0.shp'
arcpy.Copy_management(infc, outshp) 


or this:

import arcpy, sys, os, string
infc = r'C:\temp\basedata\SK_BS.gdb\BS_1250009_0'
outshp = 'BS_1250009_0.shp'
outpath = r'C:\temp\Basedata_shps'
arcpy.env.workspace = outpath
arcpy.Copy_management(infc, outshp) 


When you use the full shp path coupled with setting the arcpy.env.workspace, ArcPy gets confused because you are basically then saying the outputshapefile should be:

r'C:\temp\Basedata_shps\C:\temp\Basedata_shps\BS_1250009_0.shp'

Personally I almost always use the full path to a dataset instead of setting the workspace. It is cleaner and the code is easier to read/follow.
0 Kudos
ChrisSnyder
Regular Contributor III
My bad...

Use the CopyFeatures tool. The Copy tool will not reformat the data (FGDB to shp), but CopyFeatures will. The item in my other post probably wouldn't hurt either...
Paula_Lopes
New Contributor II

I confirm CopyFeatures is much better! 😀

Although my task was to copy feature classes between mobile geodatabases (*.geodatabase), setup CopyFeatures was easier than Copy. 

 

0 Kudos