0

The script below was exported from ModelBuilder and runs within ModelBuilder in about 7.5 seconds.

However when I export it and try to run it as a standalone script in either PyScripter or the default Python IDLE it creates a schema lock on the DB and never ends...I have let it run for an hour.

There is no error it simply never completes the task.

Any ideas on how to trouble shoot this or why it works in ModelBuilder but not as a standalone?

I'm using ArcGIS 10.2 for Desktop with a Basic level license.

    import arcpy

    arcpy.env.overwriteOutput = True

    # Local variables:
    Wells_csv = "c:\\xx\\Wells.csv"
    Wells_Layer = "Wells_Layer"
    wells = "c:\\xx\\wells"

    # Process: Make XY Event Layer
    arcpy.MakeXYEventLayer_management(Wells_csv, "Surface_Longitude", "Surface_Longitude", Wells_Layer, "GEOGCS['GCS_North_American_1927',DATUM['D_North_American_1927',SPHEROID['Clarke_1866',6378206.4,294.9786982]],PRIMEM['Greenwich',0.0],UNIT['Degree',0.0174532925199433]];-400 -400 1000000000;-100000 10000;-100000 10000;8.98305509728916E-09;0.001;0.001;IsHighPrecision", "")

    # Process: Copy Features
    arcpy.CopyFeatures_management(Wells_Layer, wells, "", "0", "0", "0")
1

The Help page entitled Exporting a model to a Python script lists a number of caveats when using this technique as an aid to learn Python/ArcPy.

I far prefer to run tools manually via their tool dialogs and then to use Geoprocessing | Results to access Copy As Python Snippet and then Paste that well-formed code into a Python script instead.

In your case the script only uses two tools so I recommend running each from its tool dialog with the same parameters, and assuming it works, start writing a new script using Copy As Python Snippet.

If either tool fails to complete then this is a problem with the tool rather than ArcPy (or PyScripter/IDLE).

  • that's a good suggestion and attempted it....but now I have discovered that the arcpy.CopyFeatures_management is the problem when I run it from the toolbox it just runs and does not make any progress, but it works from model builder – risail Mar 4 '15 at 22:27
  • @Dan I think you should research/ask about why Copy Features (after Make XY Event Layer) may not be working separately. I would focus on the contents of that *.csv file. For example, check whether all works when you reduce it to a few rows. – PolyGeo Mar 4 '15 at 22:34
  • it works in model builder so I know it is not an issue with the CSV, the issue is now when I manualy use Datamanagment>Features>CopyFeatures or attempt to use it in a script – risail Mar 4 '15 at 22:37
  • I've assumed that you have taken care not to have any schema locks around by closing all applications (rebooting to be absolutely sure) and then just running the script from IDLE. – PolyGeo Mar 4 '15 at 22:41
  • I have but a schema lock would prevent the command form starting with an error, I can't even get an error its like I am stuck in an endless loop....I am going to try to convert my created feature class to something else maybe a shape before sending it to the DB. – risail Mar 4 '15 at 22:44

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.