Cannot open .exe after pyinstaller convert

OfficialAhmed

Running my GUI application created in PyQt5 using any IDLE or the file.py is running perfectly, however, when I converted the .py to .exe using Pyinstaller I get an error every time I try to run the .exe file for some reason a small command window pops with an error and immediately disappear I screenshot the error before it closes. Any Idea Thanks in advance

Error image.

I tried to execute different commands for pyinstaller but no luck.

<pyinstaller filename -F > 
<pyinstaller filename -onefile >
<pyinstaller filename >

It's an app over 900 lines and I cannot upload all of that but I think according to the error first lines. The error occurs so here are the lines of code. The problem is within importing modules I believe.

from PyQt5.QtWidgets import QWidget
from PyQt5 import QtCore, QtGui, QtWidgets
from datetime import datetime
import time
import os, sys  #importing system modules

class Ui_MyTrophiesWindow(object):
    class save_txt_file(QWidget): 
     def GetSaveFile(self):
            path = QFileDialog.getSaveFileName(self,"Save MyTrophies.txt here", "MyTrophies", "*.txt")
            working_path = os.path.abspath(__file__)[0:-13]
            file = open(str(working_path) + "Txtpath.dat", "w+")
            for i in path:
                file.write(str(i))
            file.close()
Masoud Rahimi

It is very common that sometimes PyInstaller won't recognize all Qt5 dependencies especially QT core DLLs. A simple way is to just locate that file on your current Python path and feed it with add-data flag in PyInstaller. Also, I suggest you not to use upx with PyQt as it may corrupt some DLLs:

pyinstaller --noupx -F --add-data "<Python_path>/Lib/site-packages/PyQt5/Qt/bin/Qt5Core.dll;./PyQt5/Qt/bin" script.py

To verify the answer suppose below example:

import traceback
import os
import sys


def func():
   from PyQt5.QtWidgets import QWidget
   from PyQt5 import QtCore, QtGui, QtWidgets


try:
   if getattr(sys, 'frozen', False):
      print(sys._MEIPASS)
   func()
   print("Import OK!")
except Exception:
   traceback.print_exc()

input()

After you run the executable you would see the path for Pyinstaller (something like C:\Users\User\AppData\Local\Temp\_MEI90202), go to this path and search for the Qt5Core.dll and check if it is there.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

pyinstaller exe file does not open

Cannot open Zip file after creation with tar.exe

I can not get pyinstaller to convert anything to .exe

Pygame not loading png after making .exe with Pyinstaller

Working code crashing after made into an EXE by pyinstaller

How to fix error with pyinstaller after compilation in exe

Pyinstaller program: Cannot open self Dev\dist\view\view.exe or archive Dev\dist\view\view.pkg

Why does Pyinstaller exe open and close then open again?

How to make my PyInstaller exe program open on the default browser

PyQt5 GUI - exe made with PyInstaller doesn't open

I'm not able to convert my python file into a exe using pyinstaller

exe file produced by pyinstaller cannot be used in other's PC

CX Freeze No mpl_toolkits Module found error and Pyinstaller Cannot open self .exe when I copy it to other location other than C drive

is there a way to record video after creating exe using pyinstaller

Cannot open sockets after suspend

cannot open report after save

Cannot create the exe file (LNK1104 cannot open file)

Reducing size of pyinstaller exe

PyInstaller .exe file not working

Pyinstaller compile to exe

Exe to python with pyinstaller?

Pyinstaller *.exe in TaskScheduler

Pyinstaller cant make an exe

pyinstaller exe with pubsub

convert python3.5 codes to exe file using pyinstaller warnout missing module

How to convert a Python Script constains Pyomo, GLPK, IPOPT to single exe app with Pyinstaller

Pyinstaller .exe cannot find _tiffile module - Loading of some compressed images will be very slow

Pyinstaller created exe file cannot load Decision Tree model using joblib

windows Command prompt vanishes after running a python script converted to .exe using pyinstaller

TOP Ranking

  1. 1

    Failed to listen on localhost:8000 (reason: Cannot assign requested address)

  2. 2

    How to import an asset in swift using Bundle.main.path() in a react-native native module

  3. 3

    Loopback Error: connect ECONNREFUSED 127.0.0.1:3306 (MAMP)

  4. 4

    pump.io port in URL

  5. 5

    Spring Boot JPA PostgreSQL Web App - Internal Authentication Error

  6. 6

    BigQuery - concatenate ignoring NULL

  7. 7

    ngClass error (Can't bind ngClass since it isn't a known property of div) in Angular 11.0.3

  8. 8

    Do Idle Snowflake Connections Use Cloud Services Credits?

  9. 9

    maven-jaxb2-plugin cannot generate classes due to two declarations cause a collision in ObjectFactory class

  10. 10

    Compiler error CS0246 (type or namespace not found) on using Ninject in ASP.NET vNext

  11. 11

    Can't pre-populate phone number and message body in SMS link on iPhones when SMS app is not running in the background

  12. 12

    Generate random UUIDv4 with Elm

  13. 13

    Jquery different data trapped from direct mousedown event and simulation via $(this).trigger('mousedown');

  14. 14

    Is it possible to Redo commits removed by GitHub Desktop's Undo on a Mac?

  15. 15

    flutter: dropdown item programmatically unselect problem

  16. 16

    Change dd-mm-yyyy date format of dataframe date column to yyyy-mm-dd

  17. 17

    EXCEL: Find sum of values in one column with criteria from other column

  18. 18

    Pandas - check if dataframe has negative value in any column

  19. 19

    How to use merge windows unallocated space into Ubuntu using GParted?

  20. 20

    Make a B+ Tree concurrent thread safe

  21. 21

    ggplotly no applicable method for 'plotly_build' applied to an object of class "NULL" if statements

HotTag

Archive