brief introduction : Sometimes when we need to be without Python Environmental windows Computer runtime service , You need to generate .exe End of the file to execute .nuitka Pack fast , Start super fast , Support third-party libraries that are not needed in the project. You can choose not to package together , Reduce unnecessary bundling .
Related strategies :
python: py collect files exe Run the program independently
install :
pip install -i https://pypi.douban.com/simple nuitka
Source code of case :
# -*- coding: utf-8 -*-
# time: 2022/6/9 14:15
# file: main.py
# author: tom
# official account : Play with test development
# -*- coding: utf-8 -*-
import datetime
print(datetime.datetime.now())
Click on pycharm Of Terminal Button , Enter the command to package the project :
nuitka --standalone --show-memory --show-progress --nofollow-imports --follow-import-to=utils,src --output-dir=out main.py
Parameter description :
--standalone: Easy to transplant to other machines , No more installation python
--show-memory --show-progress: Show the progress of the whole installation
--nofollow-imports: Do not compile all of the import
--follow-import-to=utils,src: It needs to be compiled into C++ The code specifies 2 A folder containing the source code , Here we use , To separate .
--output-dir=out: Specify the output result path as out.
--windows-disable-console: function exe Cancel the box .
Packing is done :
function :cmd - main.exe
WeChat official account : Play with test development
Welcome to your attention , Common progress , thank you !