In an attempt to render an interactive window via matplotlib I am using an out of process script in a toolbox. If I debug the script, it is possible to step through and render the window as expected. Running it through ArcMap (not in debug mode) causes a 000714 error.
- Running the script out of process
- Tested with background processing on and off (Geoprocessing Options)
- pythonExe is being properly found
import multiprocessing import sys, os import arcpy import matplotlib.pyplot as plt def show_form(): fig = plt.figure() x = range(10) y = range(10) plt.plot(x,y) plt.show() def main(): pythonExe = os.path.join(sys.exec_prefix, 'python.exe') multiprocessing.set_executable(pythonExe) multiprocessing.freeze_support = True jobs =  pool = multiprocessing.Pool(1) jobs.append(pool.apply_async(show_form,)) pool.close() pool.join() del pool del jobs arcpy.SetParameterAsText(0, True) if __name__ == "__main__": main()
As per Luke's comment, I tested
cmd.exe /C test.py. Other than the long import time for arcpy the script executed as expected with the Tk plot window appearing.
By opening a command window and quickly snapping a screen capture, I can grab an error from the script before it dies. This looks like an issue loading the libraries (32 vs. 64bit?)
Arcmap is using the 64bit python by default when running out of process. The next step is to figure out how to disable this, as it appears to be causing a Tk issue as @Luke suggested.