I have a script which creates a vector tile package. I am receiving the error: ERROR 001856: Cached scale doesn't match tiling scheme only when I run the tool from a standalone Python script. I use the same parameters in the GUI of ArcGIS Pro and the tool works fine. Is this an ArcPy bug? If I don't use a min and max scaling the tool runs successfully but takes forever due to the size of the dataset.
Here is my script:
<SPAN class="keyword token">from</SPAN> arcgis<SPAN class="punctuation token">.</SPAN>gis <SPAN class="keyword token">import</SPAN> GIS
<SPAN class="keyword token">import</SPAN> os
<SPAN class="keyword token">import</SPAN> arcpy
<SPAN class="comment token">#set environment settings</SPAN>
gis <SPAN class="operator token">=</SPAN> GIS<SPAN class="punctuation token">(</SPAN><SPAN class="string token">"myportal"</SPAN><SPAN class="punctuation token">)</SPAN>
arcpy<SPAN class="punctuation token">.</SPAN>env<SPAN class="punctuation token">.</SPAN>overwriteOutput <SPAN class="operator token">=</SPAN> <SPAN class="token boolean">True</SPAN>
outputPath <SPAN class="operator token">=</SPAN> r<SPAN class="string token">"\\myOutPath\"</SPAN>
arcpy<SPAN class="punctuation token">.</SPAN>env<SPAN class="punctuation token">.</SPAN>parallelProcessingFactor <SPAN class="operator token">=</SPAN> <SPAN class="string token">"66%"</SPAN>
<SPAN class="comment token"># Loop through the project, find all the maps, and</SPAN>
<SPAN class="comment token"># create a vector tile package for each map,</SPAN>
<SPAN class="comment token"># using the same name as the map</SPAN>
p <SPAN class="operator token">=</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>mp<SPAN class="punctuation token">.</SPAN>ArcGISProject<SPAN class="punctuation token">(</SPAN>r<SPAN class="string token">"\\CPVektrTile.aprx"</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="keyword token">for</SPAN> m <SPAN class="keyword token">in</SPAN> p<SPAN class="punctuation token">.</SPAN>listMaps<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">:</SPAN>
<SPAN class="keyword token">print</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="string token">"Indexing "</SPAN> <SPAN class="operator token">+</SPAN> m<SPAN class="punctuation token">.</SPAN>name<SPAN class="punctuation token">)</SPAN>
arcpy<SPAN class="punctuation token">.</SPAN>CreateVectorTileIndex_management<SPAN class="punctuation token">(</SPAN>m<SPAN class="punctuation token">,</SPAN> outputPath <SPAN class="operator token">+</SPAN> m<SPAN class="punctuation token">.</SPAN>name <SPAN class="operator token">+</SPAN> <SPAN class="string token">'.shp'</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">"ONLINE"</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">""</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="number token">10000</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="keyword token">print</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="string token">"Packaging "</SPAN> <SPAN class="operator token">+</SPAN> m<SPAN class="punctuation token">.</SPAN>name<SPAN class="punctuation token">)</SPAN>
arcpy<SPAN class="punctuation token">.</SPAN>management<SPAN class="punctuation token">.</SPAN>CreateVectorTilePackage<SPAN class="punctuation token">(</SPAN>m<SPAN class="punctuation token">,</SPAN> outputPath <SPAN class="operator token">+</SPAN> m<SPAN class="punctuation token">.</SPAN>name <SPAN class="operator token">+</SPAN> <SPAN class="string token">'.vtpk'</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">"ONLINE"</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">""</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">"INDEXED"</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="number token">100000</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="number token">3000</SPAN><SPAN class="punctuation token">,</SPAN> r<SPAN class="string token">"\\CPAreas.shp"</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="keyword token">print</SPAN> <SPAN class="punctuation token">(</SPAN><SPAN class="string token">"Adding VTPK to Test Portal"</SPAN><SPAN class="punctuation token">)</SPAN>
vtpk_item <SPAN class="operator token">=</SPAN> gis<SPAN class="punctuation token">.</SPAN>content<SPAN class="punctuation token">.</SPAN>add<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">{</SPAN><SPAN class="punctuation token">}</SPAN><SPAN class="punctuation token">,</SPAN> data<SPAN class="operator token">=</SPAN>outputPath <SPAN class="operator token">+</SPAN> m<SPAN class="punctuation token">.</SPAN>name <SPAN class="operator token">+</SPAN> <SPAN class="string token">'.vtpk'</SPAN><SPAN class="punctuation token">,</SPAN> folder<SPAN class="operator token">=</SPAN><SPAN class="string token">'packages'</SPAN><SPAN class="punctuation token">,</SPAN> overwrite<SPAN class="operator token">=</SPAN><SPAN class="token boolean">True</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="keyword token">print</SPAN> <SPAN class="punctuation token">(</SPAN><SPAN class="string token">"Publishing & Overwriting VTPK to Test Portal"</SPAN><SPAN class="punctuation token">)</SPAN>
vtpk_layer <SPAN class="operator token">=</SPAN> vtpk_item<SPAN class="punctuation token">.</SPAN>publish<SPAN class="punctuation token">(</SPAN>overwrite<SPAN class="operator token">=</SPAN><SPAN class="token boolean">True</SPAN><SPAN class="punctuation token">)</SPAN>
vtpk_layer<SPAN class="punctuation token">.</SPAN>share<SPAN class="punctuation token">(</SPAN>groups<SPAN class="operator token">=</SPAN><SPAN class="string token">"SCG - Cathodic Protection"</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>Screenshot of successful run from geoprocessing tool in ArcGIS Pro:

Code sent to Python Window from history:
arcpy<SPAN class="punctuation token">.</SPAN>management<SPAN class="punctuation token">.</SPAN>CreateVectorTilePackage<SPAN class="punctuation token">(</SPAN><SPAN class="string token">"CPAreas"</SPAN><SPAN class="punctuation token">,</SPAN> r<SPAN class="string token">"C:\db\vtpktest_2.vtpk"</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">"ONLINE"</SPAN><SPAN class="punctuation token">,</SPAN> None<SPAN class="punctuation token">,</SPAN> <SPAN class="string token">"INDEXED"</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="number token">100000</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="number token">3000</SPAN><SPAN class="punctuation token">,</SPAN> r<SPAN class="string token">"\\\CPAreas.shp"</SPAN><SPAN class="punctuation token">,</SPAN> None<SPAN class="punctuation token">,</SPAN> None<SPAN class="punctuation token">)</SPAN>
<SPAN class="line-numbers-rows"><SPAN></SPAN></SPAN>