Creating EXE of tkinter python script
<p>I'm having some trouble bundling the following python script into a single executable using pyinstaller (or py2exe or cxfreeze). I'm including only the pyinstaller code I've been trying to save space, but if anyone has any ideas to make it work with any other program feel free to let me know.</p>

<pre><code>pyinstaller --hidden-import=matplotlib --hidden-import=numpy --hidden-import=tkinter --windowed --one-file script.py
</code></pre>

<p>I've tried variations of the above, and I keep getting a "failed to execute script pyi_rth_pkgres" error when I try to open the EXE file.</p>

<pre><code>import matplotlib
matplotlib.use('TkAgg')
import numpy as np
from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg
import matplotlib.pyplot as plt
import tkinter as tk

class Application(tk.Frame):
    def __init__(self, master=None):
        tk.Frame.__init__(self,master)
        self.createWidgets()

    def createWidgets(self):
        fig=plt.figure(figsize=(8,8))
        ax=fig.add_axes([0.1,0.1,0.8,0.8],polar=True)
        canvas=FigureCanvasTkAgg(fig,master=root)
        canvas.get_tk_widget().grid(row=0,column=1)
        canvas.show()

        self.plotbutton=tk.Button(master=root, text="plot", command=lambda:self.plot(canvas,ax))
        self.plotbutton.grid(row=0,column=0)

    def plot(self,canvas,ax):
        c = ['r','b','g']  # plot marker colors
        ax.clear()         # clear axes from previous plot
        for i in range(3):
            theta = np.random.uniform(0,360,10)
            r = np.random.uniform(0,1,10)
            ax.plot(theta,r,linestyle="None",marker='o', color=c[i])
            canvas.draw()

root=tk.Tk()
app=Application(master=root)
app.mainloop()
</code></pre>

<p>I know this is pretty vague, but I thought I'd throw it out there to see if anyone had any idea where I'm going wrong/what might be the issue.</p>

<p>Thanks!</p>

<p>EDIT: I'm using Python 3.5, but if anyone can get it to work with a different version that'd be great too. I've tried other versions but still no luck.</p>