Modern Python Projects Transcripts
Chapter: Let's build an app
Lecture: Create a Windows exe file

Login or purchase this course to watch this video and the rest of the course contents.
0:00 In this and the next lesson we're going to build the gui application using the Windows
0:05 operating system. I'm running windows 10 on a virtual machine,
0:09 and it's a brand new installation,
0:11 so I haven't actually configured anything,
0:14 and it's going to be fun to use because I haven't been using Windows since ages
0:19 and I'm not really sure how things works here,
0:23 but, well, let's give it a try.
0:25 First, we need to install Python,
0:27 so let's open the browser. Last time I used Windows,
0:30 it was still using Internet Explorer,
0:33 and you mostly used it to download the different browser.
0:36 But I've heard that edge is now much better.
0:40 This is going to be a bit slow.
0:41 As I said, it's a virtual machine,
0:43 so I will try to speed up some things to get a python installation.
0:48 We are going to go to the Python.org website and download the installer
0:53 From here. You might be wondering why I'm not using pyenv for gui application
1:00 that uses tkinter. The oficial installer will also install some additional bindings for tkinter
1:07 and I'm not sure if pyenvwin would do that for you.
1:14 You can of course use Still,
1:15 use pyenvwin. There is nothing wrong with installing one python version with the
1:20 oficial python installer and then using pyenvwin to install different python versions.
1:28 So that's what I would recommend you to do.
1:30 First time you start using windows,
1:33 you install the oficial python version,
1:35 probably the latest one available, and then you use it to,
1:40 install pyenvwin, and then you use pyenvwind\ to install any additional
1:44 python versions. So make sure you click at python 3.9 to path,
1:56 and I will go through the customized installation, so we can see what's happening.
2:03 Documentation is not really necessary, but you can leave it.
2:06 This part is very important. Those are the additional dependencies that we will need for
2:12 tkinter, so make sure this is clicked and the rest is up to you
2:17 Okay, once installation is finished,
2:46 we can probably also click that because it looks important.
3:02 And now let's grab the files from the host folder.
3:06 So, I go here and let me just copy the whole folder.
3:13 I have so many files because I have the virtual environment there and we are copying
3:19 all the install packages. I could remove it to make this copying a bit faster
3:23 but it's too late now,
3:25 so I'm just going to speed up the video,
3:30 Okay? Once we have that,
3:32 let me drag this to the middle.
3:35 Come on. Oh, man.
3:37 This machine is so slow, let's go inside and clean up a little bit.
3:45 We don't need build. We don't need this.
3:47 Oh, wronng key. I keep pressing the command key instead of control.
3:53 No, I don't want to start menu.
3:55 Go away. How do I close it?
4:00 Okay. Come on. Stop doing that.
4:06 One by one. No Not this button.
4:10 Sorry. This this this and this goes away.
4:17 Uh, not this button. And inside here,
4:23 this goes away and the rest stays.
4:29 And I want to see the hidden files to remove the venv.
4:33 So this goes away. You can see there's a lot of files here.
4:38 This goes away, this and this goes away,
4:43 and here everything looks fine. All right,
4:46 so now we have basically the same files that we had when we started this chapter
4:50 Now I have to create a virtual environment and install all the additional packages.
4:58 So, how did I do this on Windows?
5:01 I guess we have to find a command line.
5:07 Ha there is. I hope so.
5:19 No, there is, Let's move our files here.
5:29 So now we should be able to run python command and have something here.
5:35 Yes, we do have Python.
5:37 So let's create a virtual environment.
5:42 And now I have to activate it.
5:45 So I need to find the equivalent of source command on the windows.
5:50 Let's go inside this folder and see what we have there.
6:04 I guess I can run the activate.bat
6:09 Yes. Perfect. All right,
6:12 let's go up and let's install all the dependencies and let's see if we can run
6:30 our guptimer. Okay.
6:34 Perfect. It's working. Great.
6:40 That was actually pretty smooth experience so far.
6:45 Okay, let's install pyinstaller and let's try to create a package.
7:02 Once we have that, let's try to build our package.
7:10 Oops, Different kind of slash.
7:13 I forgot. We're using backslash here.
7:24 Looks like everything was successful. Awesome.
7:43 We have the gui.exe file and that it's starting our uptimer.
7:51 Let's make sure that it still works and it does work indeed.
8:03 Great. Let's run pyinstaller one more time to create one file with everything bundled
8:10 just as we did for Mac OS.
8:13 And then in the next video,
8:15 I will use a yet another clean Windows virtual machine,
8:19 and we'll try to run this package.
8:38 Cool. I have the gui.exe,
8:49 and it even has the pyinstaller icon.
8:53 That's so nice. So, now I'm going to take this exe file and move it
8:58 to a clean new Windows installation that doesn't even have python install,
9:03 and then we'll check if it still works,
9:05 so I will see you in the next lesson.