1 00:00:01,470 --> 00:00:03,930 So I want to show something special here. 2 00:00:03,930 --> 00:00:08,470 If I open up Idle, let's just go find it again, like we did before. 3 00:00:09,690 --> 00:00:10,785 All apps, Idle, there we go. 4 00:00:10,785 --> 00:00:17,480 Okay so I installed flask but here if I do import flask, I can't get to it, 5 00:00:17,480 --> 00:00:21,940 because I installed it in a virtualenv and I didn't install it globally. 6 00:00:21,940 --> 00:00:27,360 So if I want to use Flask to write and run my software that is 7 00:00:27,360 --> 00:00:31,360 inside a virtualenv, I have to launch idle in a special way. 8 00:00:31,360 --> 00:00:33,079 So we do python-m, 9 00:00:33,079 --> 00:00:38,100 because again we're gonna use a special module, and we do idlelib. 10 00:00:39,560 --> 00:00:40,760 And, so now we've got this. 11 00:00:40,760 --> 00:00:46,490 And If I do import flask, then no errors because it finds flask. 12 00:00:46,490 --> 00:00:47,870 All right. 13 00:00:47,870 --> 00:00:49,640 So, that's important to know. 14 00:00:49,640 --> 00:00:53,460 Inside of a virtualenv is different from outside the virtualenv. 15 00:00:53,460 --> 00:00:58,070 So what if our virtualenv gets all screwed up and we need to start over? 16 00:00:58,070 --> 00:01:01,070 I said in the last video that these were meant to be disposable, so 17 00:01:01,070 --> 00:01:03,000 let's dispose of this one. 18 00:01:03,000 --> 00:01:06,530 Before we do that though, let's get a list of the things we have installed so 19 00:01:06,530 --> 00:01:08,250 that we can install those again. 20 00:01:08,250 --> 00:01:11,070 We do that using the pip command of freeze. 21 00:01:12,230 --> 00:01:16,050 So pip freeze tells us we have these five packages installed. 22 00:01:16,050 --> 00:01:19,530 And you'll see that there's the package name on the left 23 00:01:19,530 --> 00:01:21,990 flask it's dangerous jinja two etcetera. 24 00:01:21,990 --> 00:01:25,730 And then the stable equal means install exactly this version and 25 00:01:25,730 --> 00:01:30,400 then on the right we have the version to exactly install so, we want flask version 26 00:01:30,400 --> 00:01:34,550 zero point ten point one not flask 0.10.0 or 0.10.2 or 0.5.2 or anything like that. 27 00:01:34,550 --> 00:01:35,580 We want exactly 0.10.1. 28 00:01:35,580 --> 00:01:37,950 Now we could copy and paste that. 29 00:01:37,950 --> 00:01:39,250 I don't like either. 30 00:01:39,250 --> 00:01:40,280 I'm kinda lazy. 31 00:01:40,280 --> 00:01:47,850 I don't wanna copy and paste that into a file. 32 00:01:47,850 --> 00:01:51,310 So let's do something computer do at force. 33 00:01:51,310 --> 00:01:53,320 Computers are good at doing things, right? 34 00:01:53,320 --> 00:01:54,870 All right. So we do pit freeze again. 35 00:01:56,000 --> 00:02:00,030 But before we press enter, we're gonna do a greater than symbol, and 36 00:02:00,030 --> 00:02:01,370 then we'll give it a file name. 37 00:02:03,730 --> 00:02:07,448 And we're gonna say requirements which I can't type. 38 00:02:07,448 --> 00:02:12,490 Requirements.txt and we're gonna press return. 39 00:02:12,490 --> 00:02:17,300 And if we do a dir we see that there's a requirements file in here right now. 40 00:02:17,300 --> 00:02:24,070 And, if we cat it, then it prints out the same thing as we did print prix before. 41 00:02:24,070 --> 00:02:28,870 So, the requirements .txt file name isn't a requirement [LAUGH], 42 00:02:28,870 --> 00:02:33,680 but, it is a common practice and some third party services like Heroku, for 43 00:02:33,680 --> 00:02:35,556 example, expect that file name. 44 00:02:35,556 --> 00:02:38,720 Alright so let's trash, 45 00:02:38,720 --> 00:02:43,230 let's clear our screen, let's trash this virtual environment and make a new one. 46 00:02:43,230 --> 00:02:47,360 So, I'm still in it, I'm still activated, so let's get out of it. 47 00:02:47,360 --> 00:02:52,380 Let's deactivate and let's get rid of it. 48 00:02:52,380 --> 00:02:56,960 So, the way we get rid of a directory is we do RM, and yes, 49 00:02:56,960 --> 00:03:03,030 I want to delete that, alright, and now I'm starting over. 50 00:03:03,030 --> 00:03:08,290 So I need a new virtualenv, so let's do phyton dash 51 00:03:08,290 --> 00:03:13,260 mvenv and let's call this one flask basics two, 52 00:03:13,260 --> 00:03:17,150 this is my second try and it builds the virtualenv for 53 00:03:17,150 --> 00:03:22,790 me and we have our requirements.txt file. 54 00:03:22,790 --> 00:03:26,026 And then we're gonna do pip install -r 55 00:03:26,026 --> 00:03:31,610 .\requirements.txt and it'll install everything. 56 00:03:31,610 --> 00:03:34,960 Now, I did have a couple of issues with line endings. 57 00:03:34,960 --> 00:03:39,140 If you have issues with line endings to where it's like what is it? 58 00:03:39,140 --> 00:03:41,180 Embedded null character. 59 00:03:41,180 --> 00:03:43,890 It could be that your line endings are something that 60 00:03:43,890 --> 00:03:45,370 pip isn't currently understanding. 61 00:03:45,370 --> 00:03:48,310 Just make sure the file is saved just like UTF-8. 62 00:03:48,310 --> 00:03:52,320 And the line endings are Windows or 63 00:03:52,320 --> 00:03:55,810 Linux should both work, but swap it back and forth if we need to. 64 00:03:55,810 --> 00:04:00,120 Your text editor should be able to do that unless your text editor is idle. 65 00:04:00,120 --> 00:04:03,370 In which case just install each package on it's own. 66 00:04:03,370 --> 00:04:06,660 Anyway though, you should be all set up and ready to go for 67 00:04:06,660 --> 00:04:08,070 working with Python locally.