Tag Archives: Failed to execute script main

Pyinstaller Package Error: failed to execute script main [How to Solve]

When packaging, replace the code with: pyinstaller --hidden-import=pkg_resources -F main.py Can succeed.

It was originally designed to hide the code window during packaging. The absolute path was used. This problem was solved after changing to the above code.

Usage: pyinstaller38 --hidden-import=pkg_resources -F -w -i m4.ico main.py

Pyinstaller publishes exe and pops up failed to execute script main

Detailed map traversal, teach you to master the complex gremlin query debugging method>>>

1. Press Alt + F12 in pychar to open the terminal dialog box

1.1 my project files are placed in the wxPython directory, D: learn, weather index insurance, wxPython > pyinstaller -F -w teaindex_ main.py

1.2 after running, the dist folder and build folder will be generated in the directory D: learn, weather index insurance and wxPython. My exe program is in the dist folder. Double click the EXE to pop up:

1.3 in the terminal dialog box again, run D: learn, weather index insurance, wxPython > pyinstaller -F -c teaindex_ Main.py, run exe, you can see the problem, the lack of module typedefs

You should use: pyinstaller – F – C demo.py. After packaging, click exe to execute the file. If an error is reported, it will be displayed on the console. This is, to prepare for the screenshot, because the console error is a flash

1.4 refer to online solutions

Change the packing code to:

D:\learn\Weather index insurance\wxpython> pyinstaller -F -c teaindex_ main.py –hidden-import sklearn.neighbors.typedefs

The problem is solved! The executable file is generated successfully

1.5 generate the program with icon D: learn, weather index insurance, wxPython > pyinstaller -F -w -i sunny.ico teaindex_ main.py –hidden-import sklearn.neighbors.typedefs

1.6 can find existing pyqt5 plugin directories when packaging. The specific screenshot is as follows

Solution:

Search pyqt5 with everything, find the pyqt5 folder under the path of/library/plugins, and copy the DLL Dynamic Library pyqt5qmlplugin.dll

According to the path of the error prompt, create a new folder one by one, and form the directory C:: (qt5b) QT_ 1524647842210\_ h_ Env library plugins, copy the DLL dynamic library just copied in

1.7 in addition to the above module, no module named ‘sklearn. Utils_ cython_ Blas’, add this module to the end, as shown below

pyinstaller -F -w teaindex_ main.py –hidden-import sklearn.neighbors.typedefs –hidden-import sklearn.utils._ cython_ blas