[GIS] Compress – ERROR 000837: The workspace is not the correct workspace type

arcmaparcpy

Getting an error with a very simple compress script.

This script works perfectly fine within arcmap, but I want to make this into a scheduled recurring script.

import arcpy
from arcpy import env

env.workspace = r"\\UNC PATH \dbconnection.sde"
arcpy.Compress_management(r"\\UNC PATH \dbconnection.sde")

Super simple. I've tried importing arceditor in order to set the product for ArcGIS Desktop standard, to no avail. I've also attempted to run:

arcpy.ClearWorkspaceCache_management()

before setting env.workspace, but still doesn't work. I have also tried different variations of the UNC path, such as specifying parent folder in workspace and then only the .sde in the compress, etc…

All errors come out as the one in the title: ERROR 000837: The workspace is not the correct workspace type.

Best Answer

Hate to answer my own question. But I found the culprit of the problem.

I had a co-worker copy over their python27 directory, which is the one specifically created by ArcDesktop during installation (I realized I had forgot mine had gotten uninstalled, and then reinstalled by a standard python27 install).

According to ESRI's help, you should just have to point your python installation to include site-packages from the ARCGISDesktop/arcpy, bin, and scripting directories. This doesn't seem entirely true. I noticed a difference in the python27/DLLs folder, where there were 3 files (all starting with nc*) that were arcpy related. I copied those from his directory to mine, and it now works perfectly.

Not sure what these files do, as I haven't taken the time to go through them. I'm also not sure why this would throw a workspace error, when it should throw something more specific to a file missing error.