ImportError: No module named FileDialog - after PyInstaller

I wrote a program which I tried to turn into an executable using PyInstaller. It looks like Pyinstaller finished without any errors and I ended up with the application in / dist / my_program. However, when I try to run this application, the console window blinks for a second with a trace:

Edit: I copied the traceback. There may have been an error as I had to type it from the screenshot because it only flashes.

Traceback (most recent call last):
File "<string>", line 14, in <module>
File "C:\Users\user\desktop\PyInstaller-2.1\PyInstaller\loader\pyi_importers.py", line 270, in load_module
exec(bytecode, module.__dict__)
File "C:\Users\user\desktop\PyInstaller-2.1\my_program\build\my_program\out00-PYZ.pyz\matplotlib.pyplot", line 108, in <module>
File "C:\Users\user\desktop\PyInstaller-2.1\my_program\build\my_program\out00-PYZ.pyz\matplotlib.backends", line 32, in pylab_setup
File "C:\Users\user\desktop\PyInstaller-2.1\PyInstaller\loader\pyi_importers.py", line 270, in load_module
exec(bytecode, module.__dict__)
File "C:\Users\user\desktop\PyInstaller-2.1\my_program\build\my_program\out00-PYZ.pyz\matplotlib.backends.backend_tkagg", line 7, in <module>
File "C:\Users\user\desktop\PyInstaller-2.1\my_program\build\my_program\out00-PYZ.pyz\six", line 194, in load_module
File "C:\Users\user\desktop\PyInstaller-2.1\my_program\build\my_program\out00-PYZ.pyz\six", line 108, in _resolve
File "C:\Users\user\desktop\PyInstaller-2.1\my_program\build\my_program\out00-PYZ.pyz\six", line 779, in _import_module
ImportError: No module named FileDialog

      

The following are the imports I have in my code:

import Tkinter
from tkFileDialog import askopenfilename
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.mlab as mlab
from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg
import subprocess
from PIL import Image, ImageTk
import os

      

Does anyone know what is causing this / what the fix is? I'm guessing the error is the import of tkFileDialog?

Edit2: The program works fine when I run it in my interpreter (Spyder), but when I packaged it with PyInstaller, the resulting application gives this error.

+3


source to share


1 answer


As per this question, the addition import FileDialog

solves the problem. Matplotlib seems to need this.
However, I used Pyinstaller on a script that also imported matplotlib and does not give such an error. So I don't know what the problem is, the problem is here.



+7


source







All Articles