Search code examples
python-3.xtkinterpyinstaller

failed to execute script py to exe with pyinstaller


I read 10+ related topics but neither one of them had a solution for me.

I have the following modules included:

import sys
import os
import cv2
import xlsxwriter
from tkinter import *
from tkinter import ttk
from tkinter import filedialog
from tkinter.messagebox import showinfo

And tried several methods:

  • pyinstaller.exe -F --onefile --windowed --hidden-import "cv2" --icon=arc.ico tkinter_popup.py (it opens a console but then my system deletes it automatically for being malicious
  • pyinstaller.exe --onefile --icon=arc.ico tkinter_popup.py (Fatal error - can't access script)
  • pyinstaller.exe --icon=arc.ico tkinter_popup.py (Fatal error - can't access script)

It doesn't matter if it will work as single folder or single file. I prefer a single file output but if isn't possible a single folder will work as well.

I tried with 3.8.5 and 3.7.

Any ideas?


Solution

  • I have chosen an icon that was used both as icon and as logo. After I compiled it without that icon, everything works and both laptops. If I wanted to specify the full path, than it worked only on my laptop, that has that specific user(path). If I wanted to specify only the icon path ex 'ico.icon', than it was generating a fatal error. After deleting the icon and all the references to it, everything works like a charm.