0

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.

  • What does arcpy.Exists on the workspace you're using return? (just to rule out) – DWynne Nov 10 '15 at 18:34
  • @DWynne arcpy.Exists comes out True I recently just tried arcpy.ListUsers() on that workspace, and it came out with being unable to access that sde. – disflux Nov 10 '15 at 19:33
2

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.

  • Yeah, if you have an ESRI installation of Python, you're pretty much out of luck ever trying to install another version of Python on your machine...something will inevitably get screwed up, and you'll end up having to reinstall Arc. – Tom Nov 10 '15 at 20:42
0

If you're using the letter r to process the string as raw, you will need to place it outside the quotation marks:

r"\\UNC PATH \dbconnection.sde"
  • Sorry, that was just a typo. It is. – disflux Nov 10 '15 at 18:10
0

This might be related to ArcPy needing to be run through ArcGIS. I have found a couple other questions that may be able to help you out.

Using ArcPy Outside of ArcMap

Running ArcPy Script in Task Scheduler

  • @ MaryBeth. Thanks for these. I ran across these when trying to troubleshoot the problem. You are able to use ArcPy outside of ArcGIS, however, as those posts show, it can be quite the pain. I ended up solving the issue, but thanks for the help! – disflux Nov 10 '15 at 20:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.