I'm running the following tool in ArcGIS 10. I have an ArcPy Script like this:

import arcpy
from arcpy import env
fcRows = arcpy.SearchCursor(fc, "OBJECTID = 11365")
for row in fcRows: 
   print "I found one"

The feature with OBJECTID 11365 is just created.

It can find the feature if I run it as standalone script. But when I run it in the ArcMap's interactive python window or import it into a ArcTool toolbox and then run it, it cannot find the feature.

I have to force the refresh of the SDE connection in the ArcCatalog, and then I can get the point. Or I have to wait for a while, like several hours, then it can find the point.

I tried arcpy.ClearWorkspaceCache_management() and arcpy.refreshTOC(). They do not help.

Any help is appreciated.

  • i get several errors using the interactive python shell in Arcmap, my advice is to use PyScripter.
    – geogeek
    Dec 13, 2012 at 14:05
  • I have to publish it as a geoprocessing service. So I need to test it in the toolbox first, but I got this issue. I use the interactive python window only to confirm the issue.
    – Alex
    Dec 13, 2012 at 17:02
  • You are using raw notation in this section r"C:/sde/lcimrl.sde" but that normally means that you need backslashes. perhaps remove the r from the line or replace / with \ and see if that is the issue.
    – user681
    Dec 13, 2012 at 17:25
  • tried to remove the r, no help.
    – Alex
    Dec 13, 2012 at 18:25
  • The r would not be the problem. It automatically escapes the forward slashes and is a standard way to make paths safe on Windows. Clutching at straws here but did you save/commit your new feature before searching for it? If not, it wont 'exist'. Jan 9, 2013 at 8:43

1 Answer 1


If I read this right, it sounds like you are a bit familiar with arcpy refresh issues. I believe you will be able to get by this if you use


arcpy.RefreshCatalog documentation

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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