The first one is :.py The file is directly encapsulated into exe
The second kind : The whole project is encapsulated into exe
Additional explanation :
summary
The first one is :.py The file is directly encapsulated into exe1.cmd Get into py Directory of files
remarks : stay py The directory where the file is located , Hold down shift+ Right mouse click , And then find “ Open here PowerShell window ”, You can enter the current directory
2. Enter the following code :
remarks : Use -D Made out of exe Than using -F It's a lot faster , because -F Put all the dll The files are packaged in one exe It's in (-F Now exe Will be a big , Slow loading , recommend -D)
#-w: Do not show background -i Add Icon pyinstaller -D -w -i D:\\main.ico ***.py(py file name )
The second kind : The whole project is encapsulated into exe1. Where to open the project ;
2. open cmd, Switch to the project path , Input at the console :
# To solve the coding problem chcp 65001
3. open cmd, Switch to the project path , In the console, input as :
Generate main.spec file
pyi-makespec main.py
4. Make spec file
# -*- mode: python ; coding: utf-8 -*-block_cipher = Nonea = Analysis(['main_login.py','akm_signup.py','copy_files.py','main.py','my_command.py','not_online.py','suggest_main.py','update_files.py'], pathex=['C:/Users/Lenovo/PycharmProjects/CAM_GUIDE-GZY'], binaries=[], datas=[], hiddenimports=[], hookspath=[], hooksconfig={}, runtime_hooks=[], excludes=[], win_no_prefer_redirects=False, win_private_assemblies=False, cipher=block_cipher, noarchive=False)pyz = PYZ(a.pure, a.zipped_data, cipher=block_cipher)exe = EXE(pyz, a.scripts, [], exclude_binaries=True, name='main_login', debug=False, bootloader_ignore_signals=False, strip=False, upx=True, console=True, disable_windowed_traceback=False, target_arch=None, codesign_identity=None, entitlements_file=None , icon='D:\\auto.ico' )coll = COLLECT(exe, a.binaries, a.zipfiles, a.datas, strip=False, upx=True, upx_exclude=[], name='main_login')
a.Analysis Enter all py file , And main( I am here main_login, This actually refers to your master file ) The name of a folder can be written directly , It is not necessary to write a complete file path for a folder
b.pathex Enter the path of the project in
c. If exe To customize an icon, you need to adjust entitlements_file=None here ( Be careful : Here we use -i Cannot customize icon )
entitlements_file=None , icon='D:\\auto.ico')
… The rest generally do not need to be filled
d. Use the configured spec Documentation exe:
pyinstaller -D main_login.spec
main.exe( I am here main_login.exe La ) The path is in the dist Under the folder
Additional explanation :shift+ Right mouse click + Open here PowerShell window , The effect is as follows :
summaryThis is about python Encapsulated into exe This is the end of the article , More about python Encapsulated into exe Please search the previous articles of software development network or continue to browse the relevant articles below. I hope you will support software development network more in the future !