File tree Expand file tree Collapse file tree 5 files changed +91
-0
lines changed Expand file tree Collapse file tree 5 files changed +91
-0
lines changed Original file line number Diff line number Diff line change
1
+ .venv
2
+ # 最终生成的可执行文件
3
+ dist
4
+ # 临时编译文件,无需发布
5
+ build
Original file line number Diff line number Diff line change
1
+ # PythonDemo
2
+
3
+ ## 编译
4
+
5
+ 环境检查
6
+
7
+ ``` bash
8
+ > python --version
9
+ Python 3.12.7
10
+
11
+ > pip --version
12
+ pip 25.0.1 from G:\x xx\A naconda\L ib\s ite-packages\p ip (python 3.12)
13
+
14
+ > conda --version
15
+ conda 24.9.2
16
+ ```
17
+
18
+ 依赖
19
+
20
+ ``` bash
21
+ # 如果项目有.venv就用这个
22
+ .\. venv\S cripts\a ctivate
23
+
24
+ # 如果项目没有.venv就用这个
25
+ python -m venv .venv
26
+ .\. venv\S cripts\a ctivate
27
+ pip install -r .\r equirements.txt # pip freeze > requirements.txt
28
+ ```
29
+
30
+ 编译/运行
31
+
32
+ ``` bash
33
+ # 运行
34
+ python main.py
35
+
36
+ # 可执行文件
37
+ pyinstaller --onefile main.py
38
+ ```
Original file line number Diff line number Diff line change
1
+ from flask import Flask
2
+
3
+ app = Flask (__name__ )
4
+
5
+ @app .route ('/' )
6
+ def hello ():
7
+ return "Hello World! This is a simple HTTP response."
8
+
9
+ if __name__ == '__main__' :
10
+ app .run (host = '0.0.0.0' , port = 24006 )
Original file line number Diff line number Diff line change
1
+ # -*- mode: python ; coding: utf-8 -*-
2
+
3
+
4
+ a = Analysis (
5
+ ['main.py' ],
6
+ pathex = [],
7
+ binaries = [],
8
+ datas = [],
9
+ hiddenimports = [],
10
+ hookspath = [],
11
+ hooksconfig = {},
12
+ runtime_hooks = [],
13
+ excludes = [],
14
+ noarchive = False ,
15
+ optimize = 0 ,
16
+ )
17
+ pyz = PYZ (a .pure )
18
+
19
+ exe = EXE (
20
+ pyz ,
21
+ a .scripts ,
22
+ a .binaries ,
23
+ a .datas ,
24
+ [],
25
+ name = 'main' ,
26
+ debug = False ,
27
+ bootloader_ignore_signals = False ,
28
+ strip = False ,
29
+ upx = True ,
30
+ upx_exclude = [],
31
+ runtime_tmpdir = None ,
32
+ console = True ,
33
+ disable_windowed_traceback = False ,
34
+ argv_emulation = False ,
35
+ target_arch = None ,
36
+ codesign_identity = None ,
37
+ entitlements_file = None ,
38
+ )
You can’t perform that action at this time.
0 commit comments