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 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 return lambda *args: val(*gp_fixargs(args, True)) RuntimeError: Object: Error in executing tool

The script fails when it tries to run arcpy.management.CreateFGB. Curiously this command works when I run the script within ArcGIS Pro, python IDLE shell and at command line. What could be causing this problem? 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
  • How does workGDB look like? Can you include in your question by editing it the entire error you're receiving? – umbe1987 Sep 3 at 13:35
  • I've included the entire error message block. In terms of the GDB it is just creating a GDB to start and then populating it - nothing special, but as you can see it cannot access the tool. – wunderkind Sep 17 at 7:24
  • Please check what python command prompt you are using and how do you call it. It has to to be the one started with the conda environment. But in that case its curious that arcpy can be imported anyhow... – Andreas Müller Sep 17 at 8:42
  • I'm running it from the python command prompt which is as follows: '(arcgispro-py3) C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3>' – wunderkind Sep 20 at 1:14
  • Could this problem be related to something in the registry? I had some problems with ArcGIS Pro prior to this issue so I'm starting to think it's related.. – wunderkind Sep 20 at 1:20

Your Answer

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

Browse other questions tagged or ask your own question.