I'm using ArcPy with multiprocessing to run area solar radiation tool. I keep getting this "Runtime Error The Product License has not been initialized". The script is still running and I can get results. But I wonder if this slows down the process and how I can avoid this error. Here is how I set up the multiprocessing part
# create a process pool
pool = Pool(processes=cpu_count())
I tried to change the number of processes and sometimes I didn't get this error. I'm very new to multiprocessing. Any help is appreciated!
I have the exactly the same Error. My script only uses arcpy in one step before the multiprocessing but not in the function used in the multiprocessing which is handled completely with gdal. This error occurs most of the times bu not always and apparently is related when the function modifies a numpy array or when the array is written in the band. I cannot understand what triggers the error because no arcpy method is called during the process.
def calculateStats(*args): # This function doesn't use arcpy f = functools.partial(calculateStats, in_data=in_data, z_data=z_data, out=out) with multiprocessing.Pool(processes=2) as pool: res = pool.map(f, coordinates) Traceback (most recent call last): File "<string>", line 1, in <module> File "\Local\Programs\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\Lib\multiprocessing\spawn.py", line 105, in spawn_main exitcode = _main(fd) ........ from ._arcgisscripting import * RuntimeError: The Product License has not been initialized.
I'm working in a conda env I created with its arcpy installation. However, apparently arcpy points to a different installation.
sys.executable Out: '\\Anaconda3\\envs\\py37\\python.exe' multiprocessing.__file__ Out: '\\Anaconda3\\envs\\py37\\lib\\multiprocessing\\__init__.py' arcpy.__file__ Out: '\\AppData\\Local\\Programs\\ArcGIS\\Pro\\Resources\\ArcPy\\arcpy\\__init__.py'