
NiceGUI 1.2.6 Convert Python To Window Exe | Fix Unhandled Exception Error
NiceGUI 1.2.6 Convert Python To Window Exe | Fix Unhandled Exception Error
Just show how to convert a Python script to a Windows program with #nicegui 1.2.6 by fixing the Windows’ unhandled exception error.
This video is recorded in English and has the following transcriptions in 3 languages:
CC: Cantonese (Hong Kong) (廣東話);
CC: English (英文)
CC: Chinese (Hong Kong) - Bilingual with English on top
Handle:
/ @clueple
Support me:
https://www.paypal.com/paypalme/warre…
Content
0.033 -> I just found the way to fix
2.202 -> the unhandled exception error
4.104 -> that we encountered
5.405 -> in the last video
7.173 -> Let's go
9.342 -> Let's say
10.21 -> this is my Python file
11.745 -> ng_deep_translator
15.015 -> This is my
16.716 -> app's original code
18.018 -> Pretend that you've done your code
20.153 -> I just need to add something at the back
22.889 -> Ignore any potential
24.624 -> warnings
25.291 -> That's what these lines of codes do
27.927 -> Save it
28.928 -> Alright
29.896 -> open command prompt
31.464 -> Since in my environment
33.366 -> I've already installed
34.868 -> 'pyinstaller'
36.102 -> So, where's my environment?
38.571 -> It's in my D drive
40.373 -> the 'nicegui'folder
42.609 -> This environment is called 'nicegui'
45.045 -> You can name it
46.579 -> 'your name ...' something like that
48.815 -> That's just your environment's name
51.151 -> Anyway
52.285 -> I'm going back to my environment
54.554 -> which is this one, 'nicegui'
56.923 -> Scripts, Activate
59.259 -> Then
60.06 -> Supposed, you're going to 'pip install'
63.329 -> 'pyinstaller'
64.998 -> I've already installed
66.433 -> So
67.567 -> I just
68.601 -> need to create a folder
70.236 -> where you want to install your app
72.472 -> In my case, it's my USB
74.707 -> G drive
75.909 -> So just MKDIR
79.279 -> G drive ...
80.547 -> Just name it
81.648 -> ‘testapp1’, ok
83.75 -> Now should see
85.685 -> a folder
86.886 -> called test1 ('testapp1') in G drive
90.023 -> Ok
90.723 -> It should be blank inside
92.492 -> Now, let me get in
94.427 -> this folder
95.862 -> Now I'm in the
97.397 -> G drive testapp1, the blank folder
100.733 -> I'm already
101.568 -> in virtual environment, 'nicegui'
104.304 -> You can see that I've activated it
106.639 -> The bracket here just tells you
108.608 -> that you're already activated this environment
112.078 -> In this environment
113.613 -> pyinstaller
114.647 -> this folder, which is
116.483 -> inside G drive testapp1
119.719 -> I'll ...
120.019 -> package my windows program
121.921 -> But there're some parameters
124.09 -> one directory
125.658 -> that means, create a folder
127.393 -> in my G drive testapp1
129.729 -> Ok
130.396 -> Here, I use window mode
132.665 -> I don't want to see the console
133.867 -> these kinds of black boxes
136.102 -> After that
137.103 -> I add that
138.538 -> based on which python file
140.974 -> to make my app
142.008 -> My Python file
143.209 -> is
144.21 -> G drive
145.411 -> here
146.779 -> 'ng_deep_trans'
149.182 -> Ok
149.849 -> 'ng_deep_trans.py'
153.553 -> This can be
154.32 -> your app's name
155.688 -> 'yourapp', 'name'
157.323 -> whatever you like
158.558 -> Ok
159.626 -> Supposed
160.693 -> I need to
161.261 -> 'add'
161.928 -> 'data'
162.862 -> After that
163.696 -> I need to add
164.731 -> packages required to run my app
167.934 -> But I just leave it for now
169.869 -> I'll add that later
171.304 -> Ok
172.071 -> Now, press 'enter'
173.606 -> [key pressed]
174.274 -> Ooops, typo
175.642 -> 'pyinstaller'
177.911 -> [key pressed] ok
179.746 -> and it'll start the installation process
185.051 -> Ok, done
186.619 -> Now
187.554 -> deactivate it
188.688 -> exit
189.822 -> and go back to the folder, 'testapp1'
192.725 -> this one
193.826 -> Here you see
195.295 -> two folders and 1 file have been created
197.964 -> 'build'
198.798 -> 'dist'
199.599 -> and a spec file here
201.534 -> The result is in the 'dist' folder
205.238 -> there's a folder named after
207.44 -> our python file
209.142 -> look for the execute file
211.144 -> which is here
212.145 -> When you click it
213.146 -> nothing should come out
215.014 -> It takes quite a while for the first time
217.517 -> Here, it's blank, right?
219.452 -> But
220.286 -> at least, the window is loaded
222.422 -> But it's just
223.356 -> blank
224.257 -> Why?
225.658 -> because I didn't
226.926 -> install those packages
228.528 -> required to run my app
230.163 -> so I just put it back now
232.131 -> I will go back
233.399 -> to the virtual environment folder
236.469 -> the 'nicegui' folder in D drive
239.639 -> 'Lib'
240.24 -> that's the library
241.674 -> 'site-packages'
243.543 -> 'nicegui'
244.544 -> needs
245.378 -> the package, 'nicegui'
247.08 -> alright
248.615 -> Then
249.048 -> we need
249.782 -> 'fastapi'
251.884 -> 'uvicorn'
253.553 -> and 'starlette'
255.521 -> Since my app
256.623 -> needs the 'nicegui' package
258.658 -> so you see all these packages
260.593 -> in 'site-packages' folder
262.562 -> But if your app uses other packages
265.098 -> then you have to choose
266.199 -> your own package accordingly
268.401 -> I won't go deep here
270.036 -> Since my app uses a package called
272.538 -> 'deep_translator'
274.507 -> I press
275.508 -> [ctrl] left-click to select
277.81 -> 'deep_translator' folder
279.779 -> [ctrl] [c]
280.98 -> copy it
282.015 -> to the folder, 'testapp1'
284.083 -> and then
285.084 -> 'Distribution'
286.152 -> My app folder
287.787 -> And then
288.588 -> [ctrl] [v]
289.622 -> paste it here
291.457 -> Then go back
292.525 -> to the executable
293.926 -> inside my app folder
295.795 -> Double-click it
296.929 -> It should work this time
300.433 -> Done
301.367 -> Alright, let me try
303.269 -> typing a Japanese phrase to see if ...
306.105 -> it can translate ...
308.808 -> to German
309.876 -> Ok
311.344 -> That's it
312.178 -> Hope it helps
313.346 -> Ciao
Source: https://www.youtube.com/watch?v=4eIotPSIMDM