1 00:00:00,000 --> 00:00:01,950 Python has a lot of different versions. 2 00:00:01,960 --> 00:00:04,890 Python 2 isn't really supported at all anymore, so we're 3 00:00:04,900 --> 00:00:06,780 not even going to go over Python 2, 4 00:00:07,050 --> 00:00:12,180 but Python 3.5, for example, is still very popular, and it 5 00:00:12,200 --> 00:00:14,700 doesn't support things like an f-string. 6 00:00:14,700 --> 00:00:18,830 So let's just go into our IPython here and we could do 'name 7 00:00:18,830 --> 00:00:24,600 = "Kalob", and as an f-string, we could say "Hello 8 00:00:24,600 --> 00:00:28,100 ". And it says, "Hello Kalob". 9 00:00:28,850 --> 00:00:32,210 And it just happens to be that Python 3.5 does not support 10 00:00:32,220 --> 00:00:37,540 that. So what if you're using a specific version of Python 11 00:00:37,550 --> 00:00:38,620 on a specific project? 12 00:00:38,940 --> 00:00:42,600 Let's say you just get hired at a new company and you run 13 00:00:42,610 --> 00:00:45,600 'python -V', and you're using Python 3.7, 14 00:00:45,690 --> 00:00:48,780 but they're using Python 3.8, and they're using a feature 15 00:00:48,790 --> 00:00:52,110 that's only available in Python 3.8 called the 'walrus 16 00:00:52,120 --> 00:00:55,550 operator'. Well, you can no longer use Python 3.7. 17 00:00:55,640 --> 00:00:59,020 You need to upgrade, but you don't necessarily always want 18 00:00:59,020 --> 00:01:00,700 to just upgrade to 3.8. 19 00:01:00,760 --> 00:01:05,200 You might also want to keep 3.7 around because you have other 20 00:01:05,209 --> 00:01:07,210 projects that still use Python 3.7. 21 00:01:07,420 --> 00:01:09,850 Now, for the most part, that's actually not really gonna 22 00:01:09,860 --> 00:01:12,460 be a problem, just because Python is for the most part quite 23 00:01:12,470 --> 00:01:13,330 reverse compatible. 24 00:01:13,480 --> 00:01:17,260 Meaning if you have Python 3.8 installed and your projects 25 00:01:17,270 --> 00:01:21,570 are using Python 3.7, chances are your projects using 3.7 26 00:01:21,570 --> 00:01:23,190 will probably work still. 27 00:01:23,340 --> 00:01:25,950 But there is the occasional time where that is not true. 28 00:01:26,340 --> 00:01:29,970 So given this hypothetical situation where you just get hired 29 00:01:29,980 --> 00:01:32,280 at a new company and you need to use a different version 30 00:01:32,290 --> 00:01:33,960 of Python, how do you get it? 31 00:01:33,970 --> 00:01:37,910 Well, there's a thing called 'pyenv', and if we open up our browser, 32 00:01:37,920 --> 00:01:44,550 and I think it's just 'github.com/pyenv/pyenv', I hope that's correct. 33 00:01:44,550 --> 00:01:51,400 Yep, looks like it. 'pyenv' is basically 'py environment', and that 34 00:01:51,400 --> 00:01:54,800 allows you to have different versions of Python. 35 00:01:54,860 --> 00:01:56,780 And let's read the description. 36 00:01:56,790 --> 00:01:59,810 'pyenv lets you easily switch between multiple versions of 37 00:01:59,820 --> 00:02:03,230 Python. It's simple, unobtrusive, and follows the Unix tradition 38 00:02:03,240 --> 00:02:05,210 of single-purpose tools that do one thing 39 00:02:05,220 --> 00:02:06,940 well'. I would say that's true. 40 00:02:06,950 --> 00:02:07,810 I use it quite a bit, 41 00:02:07,820 --> 00:02:10,150 I really like it. Table of contents, 42 00:02:10,150 --> 00:02:11,800 let's go down to 'Installation'. 43 00:02:11,800 --> 00:02:15,900 So if you are on a Mac, you can consider installing it with 44 00:02:15,900 --> 00:02:18,000 Homebrew, and let's click on that. 45 00:02:18,070 --> 00:02:19,440 And it is simple as 'brew. 46 00:02:19,470 --> 00:02:21,030 update, brew install pyenv'. 47 00:02:21,040 --> 00:02:23,190 If you're on a Mac, and you don't have 'brew', you might want 48 00:02:23,200 --> 00:02:25,500 to get 'Homebrew'. It is a nice little package manager. 49 00:02:25,500 --> 00:02:28,430 It's like 'pip', but for your macOS. If you're on Windows 50 00:02:28,430 --> 00:02:33,700 you're gonna have to use 'pyenv-win' because Windows is a little bit different. 51 00:02:33,750 --> 00:02:37,310 It's not really Unix based at all, whereas Mac actually has 52 00:02:37,310 --> 00:02:40,600 a little bit of Unix inner workings inside of it still. 53 00:02:40,670 --> 00:02:43,040 So if you're on Windows, definitely check out 'github.com/ 54 00:02:43,040 --> 00:02:47,700 pyenv-win/pyenv-win'. 55 00:02:47,760 --> 00:02:50,970 And so if you want, you can go ahead and get that installed. 56 00:02:50,980 --> 00:02:52,590 Now before you do that, 57 00:02:52,600 --> 00:02:58,000 if you have Anaconda installed, 'anaconda.com', 58 00:02:58,910 --> 00:03:01,280 if you have this installed, you're probably going to run 59 00:03:01,280 --> 00:03:02,200 into some problems. 60 00:03:02,200 --> 00:03:05,500 Anaconda comes with its own distribution of Python, which 61 00:03:05,510 --> 00:03:08,810 can actually compete or conflict with 'pyenv' a little bit. 62 00:03:08,820 --> 00:03:10,610 I've actually noticed that in my own experience. 63 00:03:10,610 --> 00:03:14,600 So preferably if you're going to use one, just stick with one of these. 64 00:03:14,680 --> 00:03:17,710 Now, once you have that installed, if you wanted to, you 65 00:03:17,720 --> 00:03:19,300 could just go straight to your command line here. 66 00:03:19,300 --> 00:03:21,600 Let's clear this out, and we can do 'pyenv', 67 00:03:21,600 --> 00:03:22,500 let's just type 'pyenv', 68 00:03:22,510 --> 00:03:26,200 let's see what happens. 'pyenv', 'some useful pyenv 69 00:03:26,200 --> 00:03:29,800 commands are:' - commands, local, global, shell, install, uninstall, 70 00:03:29,800 --> 00:03:32,800 rehash, version, versions, which and whence. We really only need 71 00:03:32,800 --> 00:03:36,800 a few of these. Let's do 'pyenv versions', because this one's going to list all 72 00:03:36,800 --> 00:03:39,100 the Python versions that are available on 'pyenv'. 73 00:03:39,100 --> 00:03:41,350 These are the ones that I have on my computer. 74 00:03:41,350 --> 00:03:48,000 So I currently have Python 3.5.7, 3.6.0, 3.7.2, and 3.8.0 75 00:03:48,000 --> 00:03:53,300 So if I do 'python -V', this is the version I'm using, Python 3.7.2, 76 00:03:53,300 --> 00:03:57,500 but I can now change that very easily with 'pyenv', 77 00:03:57,500 --> 00:04:00,600 and I'm going to change this across my entire system 78 00:04:00,620 --> 00:04:05,210 right now. 'pyenv global 3.5.7', 79 00:04:05,440 --> 00:04:07,990 and let's do 'python'. 80 00:04:08,860 --> 00:04:12,460 let's spell 'python' correctly, though, and look at that. 81 00:04:12,600 --> 00:04:14,640 I'm using a different version of Python now. 82 00:04:14,650 --> 00:04:17,279 And if you want to see the current version, you can literally 83 00:04:17,279 --> 00:04:21,000 just type 'python version', and it will tell you in here, not 84 00:04:21,000 --> 00:04:22,899 'python version', 'pyenv version', 85 00:04:23,339 --> 00:04:25,680 and it tells you which one you're using. 86 00:04:25,680 --> 00:04:28,200 And let's go back to, let's not go back, 87 00:04:28,269 --> 00:04:31,070 let's change our version to Python 3.8. 88 00:04:31,080 --> 00:04:35,220 So I'm going to do 'pyenv global 3.8.0', 89 00:04:35,220 --> 00:04:37,000 that's because I have that installed already. 90 00:04:37,000 --> 00:04:40,410 'pyenv versions' tells me I have it set. Now 91 00:04:40,420 --> 00:04:43,430 what happens if you want to install a new version? 92 00:04:43,430 --> 00:04:45,900 We just have to find out the version that you want, and then you can 93 00:04:45,900 --> 00:04:48,680 do 'pyenv install', and then the version name. 94 00:04:49,280 --> 00:04:50,870 Let's see what happens here. 95 00:04:52,200 --> 00:04:55,000 It'd be really great if it gave us all the version names, 96 00:04:55,700 --> 00:05:00,300 but you could effectively do 'pyenv install 3.8.0', and it will 97 00:05:00,400 --> 00:05:01,900 install it for you, and then you can use it. 98 00:05:01,960 --> 00:05:04,750 I'm actually going to go back to 3.7, because that's what 99 00:05:04,750 --> 00:05:10,000 a lot of my projects right now are using, 'pyenv global 3.7.2', 100 00:05:10,000 --> 00:05:13,700 'pyenv version', and I'm back on 3.7.2. 101 00:05:13,740 --> 00:05:15,990 Once again, there is a little bit of a conflict here. 102 00:05:16,000 --> 00:05:18,880 So if you are using Anaconda, chances are you're going to want 103 00:05:18,890 --> 00:05:20,500 to continue to use Anaconda, 104 00:05:20,500 --> 00:05:22,900 otherwise you're going to run into some pathing issues, 105 00:05:23,000 --> 00:05:27,100 and I've noticed that those issues are not the most straightforward 106 00:05:27,100 --> 00:05:28,200 problem to solve. 107 00:05:28,200 --> 00:05:34,100 But if you aren't using Anaconda, 'pyenv' is definitely a good way to go.