Run a ArcGIS Pro Model With a ArcGIS.com Feature Layer in Task Scheduler on a daily basis

2214
3
Jump to solution
07-15-2016 05:39 AM
AndrewCallison
New Contributor III

I am trying to run a ArcGIS Pro Model from Model Builder that updates fields within an ArcGIS Feature Layer. i am would like this model to doing multiple field Calculation on a daily basis as the data is updated or added. The model works as long as I running the model in ArcGIS Pro but as soon as I try to call the toolbox through python and I get back

"ERROR 000732: Input Table: Dataset Permit_Status\Permit Status does not exist or is not supported

Failed to execute (PermitDuration)".

Here is the error I receive:

Python 3.4.3 (v3.4.3:9b73f1c3e601, Feb 24 2015, 22:44:40) [MSC v.1600 64 bit (AMD64)] on win32
Type "copyright", "credits" or "license()" for more information.
>>> ================================ RESTART ================================
>>> 
Traceback (most recent call last):
  File "C:\Python34\lib\idlelib\run.py", line 353, in runcode
    exec(code, self.locals)
  File "C:\Users\agcallis\Documents\ArcGIS\Projects\Permits_Duration\PermitDuration.py", line 3, in <module>
    arcpy.PermitDuration.PermitDuration()
Traceback (most recent call last):
  File "C:\Python34\lib\idlelib\run.py", line 353, in runcode
    exec(code, self.locals)
  File "C:\Users\agcallis\Documents\ArcGIS\Projects\Permits_Duration\PermitDuration.py", line 3, in <module>
    arcpy.PermitDuration.PermitDuration()
  File "C:\Users\agcallis\Documents\ArcGIS\Projects\Permits_Duration\Permits_Duration.tbx", line 59, in PermitDuration
  File "C:\Users\agcallis\Documents\ArcGIS\Projects\Permits_Duration\Permits_Duration.tbx", line 56, in PermitDuration
  File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\geoprocessing\_base.py", line 500, in <lambda>
    return lambda *args: val(*gp_fixargs(args, True))
arcgisscripting.ExecuteError: Failed to execute. Parameters are not valid.
The value does not exist.
ERROR 000732: Input Table: Dataset Permit_Status\Permit Status does not exist or is not supported
Failed to execute (PermitDuration).




During handling of the above exception, another exception occurred:


Traceback (most recent call last):
  File "C:\Python34\lib\tokenize.py", line 374, in find_cookie
    line_string = line.decode('utf-8')
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xd0 in position 0: invalid continuation byte


During handling of the above exception, another exception occurred:


Traceback (most recent call last):
  File "C:\Python34\lib\idlelib\run.py", line 126, in main
    ret = method(*args, **kwargs)
  File "C:\Python34\lib\idlelib\run.py", line 365, in runcode
    print_exception()
  File "C:\Python34\lib\idlelib\run.py", line 216, in print_exception
    print_exc(typ, val, tb)
  File "C:\Python34\lib\idlelib\run.py", line 206, in print_exc
    tbe = traceback.extract_tb(tb)
  File "C:\Python34\lib\traceback.py", line 106, in extract_tb
    return list(_extract_tb_iter(tb, limit=limit))
  File "C:\Python34\lib\traceback.py", line 65, in _extract_tb_or_stack_iter
    line = linecache.getline(filename, lineno, f.f_globals)
  File "C:\Python34\lib\linecache.py", line 15, in getline
    lines = getlines(filename, module_globals)
  File "C:\Python34\lib\linecache.py", line 41, in getlines
    return updatecache(filename, module_globals)
  File "C:\Python34\lib\linecache.py", line 126, in updatecache
    with tokenize.open(fullname) as fp:
  File "C:\Python34\lib\tokenize.py", line 439, in open
    encoding, lines = detect_encoding(buffer.readline)
  File "C:\Python34\lib\tokenize.py", line 415, in detect_encoding
    encoding = find_cookie(first)
  File "C:\Python34\lib\tokenize.py", line 379, in find_cookie
    raise SyntaxError(msg)
SyntaxError: invalid or missing encoding declaration for 'C:\\Users\\agcallis\\Documents\\ArcGIS\\Projects\\Permits_Duration\\Permits_Duration.tbx'


During handling of the above exception, another exception occurred:


Traceback (most recent call last):
  File "C:\Python34\lib\tokenize.py", line 374, in find_cookie
    line_string = line.decode('utf-8')
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xd0 in position 0: invalid continuation byte


During handling of the above exception, another exception occurred:


Traceback (most recent call last):
  File "C:\Python34\lib\idlelib\run.py", line 138, in main
    print_exception()
  File "C:\Python34\lib\idlelib\run.py", line 216, in print_exception
    print_exc(typ, val, tb)
  File "C:\Python34\lib\idlelib\run.py", line 202, in print_exc
    print_exc(type(context), context, context.__traceback__)
  File "C:\Python34\lib\idlelib\run.py", line 202, in print_exc
    print_exc(type(context), context, context.__traceback__)
  File "C:\Python34\lib\idlelib\run.py", line 206, in print_exc
    tbe = traceback.extract_tb(tb)
  File "C:\Python34\lib\traceback.py", line 106, in extract_tb
    return list(_extract_tb_iter(tb, limit=limit))
  File "C:\Python34\lib\traceback.py", line 65, in _extract_tb_or_stack_iter
    line = linecache.getline(filename, lineno, f.f_globals)
  File "C:\Python34\lib\linecache.py", line 15, in getline
    lines = getlines(filename, module_globals)
  File "C:\Python34\lib\linecache.py", line 41, in getlines
    return updatecache(filename, module_globals)
  File "C:\Python34\lib\linecache.py", line 126, in updatecache
    with tokenize.open(fullname) as fp:
  File "C:\Python34\lib\tokenize.py", line 439, in open
    encoding, lines = detect_encoding(buffer.readline)
  File "C:\Python34\lib\tokenize.py", line 415, in detect_encoding
    encoding = find_cookie(first)
  File "C:\Python34\lib\tokenize.py", line 379, in find_cookie
    raise SyntaxError(msg)
SyntaxError: invalid or missing encoding declaration for 'C:\\Users\\agcallis\\Documents\\ArcGIS\\Projects\\Permits_Duration\\Permits_Duration.tbx'


During handling of the above exception, another exception occurred:


Traceback (most recent call last):
  File "C:\Python34\lib\tokenize.py", line 374, in find_cookie
    line_string = line.decode('utf-8')
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xd0 in position 0: invalid continuation byte


During handling of the above exception, another exception occurred:


Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "C:\Python34\lib\idlelib\run.py", line 142, in main
    traceback.print_exception(type, value, tb, file=sys.__stderr__)
  File "C:\Python34\lib\traceback.py", line 169, in print_exception
    for line in _format_exception_iter(etype, value, tb, limit, chain):
  File "C:\Python34\lib\traceback.py", line 153, in _format_exception_iter
    yield from _format_list_iter(_extract_tb_iter(tb, limit=limit))
  File "C:\Python34\lib\traceback.py", line 18, in _format_list_iter
    for filename, lineno, name, line in extracted_list:
  File "C:\Python34\lib\traceback.py", line 65, in _extract_tb_or_stack_iter
    line = linecache.getline(filename, lineno, f.f_globals)
  File "C:\Python34\lib\linecache.py", line 15, in getline
    lines = getlines(filename, module_globals)
  File "C:\Python34\lib\linecache.py", line 41, in getlines
    return updatecache(filename, module_globals)
  File "C:\Python34\lib\linecache.py", line 126, in updatecache
    with tokenize.open(fullname) as fp:
  File "C:\Python34\lib\tokenize.py", line 439, in open
    encoding, lines = detect_encoding(buffer.readline)
  File "C:\Python34\lib\tokenize.py", line 415, in detect_encoding
    encoding = find_cookie(first)
  File "C:\Python34\lib\tokenize.py", line 379, in find_cookie
    raise SyntaxError(msg)
SyntaxError: invalid or missing encoding declaration for 'C:\\Users\\agcallis\\Documents\\ArcGIS\\Projects\\Permits_Duration\\Permits_Duration.tbx'

Any help or suggest will be greatly appreciated. The main goal is to do daily field calculation on updated features inside an ArcGIS.com Feature layer using Task Scheduler.

0 Kudos
1 Solution

Accepted Solutions
AndrewCallison
New Contributor III

The Python script works within ArcGIS Pro as a script in the toolbox but will not work when trying to run the script in Python 3.4.3 IDLE with ArcGIS Pro opened in the background.

My hope is to run this script on a server using task Scheduler as a nightly process.

My python 3.4.3 Call to the toolbox.

import arcpy

arcpy.ImportToolbox(r"C:\Users\agcallis\Documents\ArcGIS\Projects\Permits_Duration\Permits_Duration.tbx", "PermitDuration")

arcpy.PermitDuration.PermitDuration(r"http://services.arcgis.com/T2graiaSQnlmwwmp/arcgis/rest/services/Permit_Status/FeatureServer")

View solution in original post

0 Kudos
3 Replies
DougBrowning
MVP Esteemed Contributor

My guess is you are not logged in. Have you tested it with Pro open in the background and logged in?

0 Kudos
AndrewCallison
New Contributor III

The Python script works within ArcGIS Pro as a script in the toolbox but will not work when trying to run the script in Python 3.4.3 IDLE with ArcGIS Pro opened in the background.

My hope is to run this script on a server using task Scheduler as a nightly process.

My python 3.4.3 Call to the toolbox.

import arcpy

arcpy.ImportToolbox(r"C:\Users\agcallis\Documents\ArcGIS\Projects\Permits_Duration\Permits_Duration.tbx", "PermitDuration")

arcpy.PermitDuration.PermitDuration(r"http://services.arcgis.com/T2graiaSQnlmwwmp/arcgis/rest/services/Permit_Status/FeatureServer")

0 Kudos
ChristopherMoore
Esri Contributor

I had this problem (Pro/Python 3 choking when loading a toolbox from command line) and the workaround from Handle python 3 choking on non-text scripts. · habnabit/passacre@2ea05ba · GitHub  seemed to work for me:

# WORKAROUND: for Python 3 choking on reading some non-binary files

# Get error like: detect_encoding...tokenize.py...find_cookie...raise SyntaxError(msg)  

# ...SyntaxError: invalid or missing encoding declaration for '...XXXX.tbx'

# Workaround borrowed/used from: https://github.com/habnabit/passacre/commit/2ea05ba94eab2d26951ae7b4b51abf53132b20f0

if sys.version_info >= (3,0):   # Code will work on Python 2, but only do workaround for Python 3
   import tokenize 
   try: 
      _detect_encoding = tokenize.detect_encoding 
   except AttributeError: 
      pass 
   else: 
      def detect_encoding(readline): 
         try: 
            return _detect_encoding(readline) 
         except SyntaxError: 
            return 'latin-1', [] 

      tokenize.detect_encoding = detect_encoding 
- Chris
0 Kudos