do a small tool, in the local execution OK, use pyinstaller packaging process, there are problems, in a variety of search on the Internet, can not find the specific problem point, it seems mainly because, in the process of the problem, the difference will be relatively big, so also need to analyze the specific problem.
local execution: python ******. Py
all normal, ready to use pyinstaller package to generate exe execution file;
package command: pyinstaller. Exe-dall *****. Py
execution will jump out of the command line black window and will execute normally.
package command: pyinstaller. Exe-w-dall *****. Py
execution occurs as follows:
packaging command: pyinstaller. Exe-w *****. Py
Failed to execute script ******
is later found because the log output is used in the following way:
import os
import io
class Logger(object):
def __init__(self, filename="Default.log", path="./"):
sys.stdout = io.TextIOWrapper(sys.stdout.buffer)
self.terminal = sys.stdout
# self.log = open(os.path.join(path, filename), "a", encoding='utf8')
self.log = open(filename, "a")
def write(self, message):
self.terminal.write(message)
self.log.write(message)
def flush(self):
pass
sys.stdout = Logger(create_detail_day() + '_grit.log', path='')#方式1
is changed as follows:
savedStdout = sys.stdout #保存标准输出流 #方式2
file = open(create_detail_day()+ '_zh_finlock_license_gen_log.txt', 'wt')
sys.stdout = file #标准输出重定向至文件
then package and use the command: pyinstaller. Exe-w *****. Py
will run normally.
The -f command is added below
to package the dependent libraries and files as a whole
package command to: pyinstaller. Exe – w – F – dall * * * * * * *. Py p>
generates exe executable, after which the following phenomenon occurs:
p>
packaging command: pyinstaller. Exe-w-f *****. Py
generates exe executables, which can be executed normally.
come to an end!
p>
Read More:
- Solutions to the problem of cannot find existing pyqt5 plugin directories encountered in pyinstaller packaging
- The problem of failed to create process occurs in pyinstaller package program of Python
- Error loading in pyinstaller packaging
- Error reporting processing of pyinstaller packaging geopandas environment
- [Unity] Solve the problem of IOException: Failed to Copy… in Unity packaging apk
- Summary of solutions to open flash back problem after Python packaging
- About the problem I encountered: 226 transfer done but failed to open directory
- Solving environment: failed solution to the problem encountered when updating Anaconda
- BarTender operation encountered the problem of “OLE DB encountered error 0x80004005”
- Failed to import module __PyInstaller_hooks_0_IPython required by hook for module
- CentOS solves the problem of modulenotfounderror when salt calls python3 script remotely, and solves the problem that PIP3 module cannot be shared by different users
- Solve the error in Ubuntu 18.04: called “net usershare info” but it failed: failed to execute child process “net”
- An undetermined call to function ‘shell’: missing ‘. Stop. Problem encountered when using shell command in makefile
- Docker encountered a problem 4: yaml: Line 1: mapping values are not allowed in this context
- To solve the problem of failed to load: data in HTML5 game running rmmv locally/ actors.json problem
- Idea2020.2 encountered pom.xml The problem of file error report in Maven plug-in tomcat7
- In thinkphp5, we encountered the problem of class’ phpoffice / phpspredsheet / spreadsheet ‘not found
- Failed to execute goal in Maven build org.apache.tomcat .maven:
- Data analysis to obtain Yahoo stock data: some problems are encountered when using panda datareader (cannot import name ‘is_ list_ Like ‘problem)