I have been following the example of 'Update Real-Time Data with Python' on https://learn.arcgis.com/en/projects/update-real-time-data-with-python/ but get a runtime error when I run the example from the python command prompt:

Traceback (most recent call last):   File "C:\Temp\coral_reef_exercise_advanced.py", line 78, in <module>
    feedRoutine (url, workGDB)   File "C:\Temp\coral_reef_exercise_advanced.py", line 18, in feedRoutine
    arcpy.management.CreateFileGDB(os.path.dirname(workGDB), os.path.basename(workGDB))   File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\management.py", line 19107, in CreateFileGDB
    raise e   File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\management.py", line 19104, in CreateFileGDB
    retval = convertArcObjectToPythonObject(gp.CreateFileGDB_management(*gp_fixargs((out_folder_path, out_name, out_version), True)))   File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\geoprocessing\_base.py", line 496, in <lambda>
    return lambda *args: val(*gp_fixargs(args, True)) RuntimeError: Object: Error in executing tool

The script fails when it tries to run arcpy.management.CreateFileGDB(). Curiously this command works when I run the script within ArcGIS Pro, python IDLE shell and at command line.

I have checked licensing and tried running it with and without an ArcGIS app open but it still fails. I have also tried creating the gdb but then the script fails when the next ArcGIS tool 'JSONToFeatures' is called.

What could be causing this behavior?

#python 3.6
import sys, os, tempfile, json, logging, arcpy
import datetime as dt
from urllib import request
from urllib.error import URLError

def feedRoutine (url, workGDB):
    # Log file
    logging.basicConfig(filename="coral_reef_exercise.log", level=logging.INFO)
    log_format = "%Y-%m-%d %H:%M:%S"
    # Create workGDB and default workspace
    print("Starting workGDB...")
    logging.info("Starting workGDB... {0}".format(dt.datetime.now().strftime(log_format)))
    arcpy.env.workspace = workGDB
    if arcpy.Exists(arcpy.env.workspace):
        for feat in arcpy.ListFeatureClasses ("alert_*"):   
        arcpy.management.CreateFileGDB(os.path.dirname(workGDB), os.path.basename(workGDB))
    # Download and split json file
    print("Downloading data...")
    logging.info("Downloading data... {0}".format(dt.datetime.now().strftime(log_format)))
    temp_dir = tempfile.mkdtemp()
    filename = os.path.join(temp_dir, 'latest_data.json')
        response = request.urlretrieve(url, filename)
    except URLError:
        logging.exception("Failed on: request.urlretrieve(url, filename) {0}".format(
        raise Exception("{0} not available. Check internet connection or url address".format(url))
    with open(filename) as json_file:
        data_raw = json.load(json_file)
        data_stations = dict(type=data_raw['type'], features=[])
        data_areas = dict(type=data_raw['type'], features=[])
    for feat in data_raw['features']:
        if feat['geometry']['type'] == 'Point':
    # Filenames of temp json files
    stations_json_path = os.path.join(temp_dir, 'points.json')
    areas_json_path = os.path.join(temp_dir, 'polygons.json')
    # Save dictionaries into json files
    with open(stations_json_path, 'w') as point_json_file:
        json.dump(data_stations, point_json_file, indent=4)
    with open(areas_json_path, 'w') as poly_json_file:
        json.dump(data_areas, poly_json_file, indent=4)
    # Convert json files to features
    print("Creating feature classes...")
    logging.info("Creating feature classes... {0}".format(dt.datetime.now().strftime(log_format)))
    arcpy.conversion.JSONToFeatures(stations_json_path, 'alert_stations') 
    arcpy.conversion.JSONToFeatures(areas_json_path, 'alert_areas')
    # Add 'alert_level ' field
    arcpy.management.AddField('alert_stations', 'alert_level', 'SHORT', field_alias='Alert Level')
    arcpy.management.AddField('alert_areas', 'alert_level', 'SHORT', field_alias='Alert Level')
    # Calculate 'alert_level ' field
    arcpy.management.CalculateField('alert_stations', 'alert_level', "int(!alert!)")
    arcpy.management.CalculateField('alert_areas', 'alert_level', "int(!alert!)")

    # Deployment Logic
    logging.info("Deploying... {0}".format(dt.datetime.now().strftime(log_format)))

    # Close Log File

    # Return
    logging.info("Done! {0}".format(dt.datetime.now().strftime(log_format)))
    return True

def deployLogic():

if __name__ == "__main__":
    [url, workGDB] = sys.argv[1:]
    feedRoutine (url, workGDB)

  [1]: https://i.stack.imgur.com/EEscd.jpg

The problem is caused by a conflict with Autodesk drainage extension - uninstall it solves the problem!

See RuntimeError: Object: Error in executing tool at GeoNet:

We nailed down the issue as a conflict between AutoCAD’s River and Flood module with ArcGIS Pro. After uninstalling that AutoCAD module we no longer have this issue on our workstations.

| improve this answer | |

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.