1 00:00:07,850 --> 00:00:11,410 Hi everyone. My name is Daniel Schorin, 2 00:00:11,410 --> 00:00:13,700 and I'm a student assistant in this class. 3 00:00:13,700 --> 00:00:15,790 Today, we'll be going over how to set up 4 00:00:15,790 --> 00:00:19,370 your local programming environment on a Mac computer. 5 00:00:19,370 --> 00:00:22,194 Starting off, while the Jupyter console 6 00:00:22,194 --> 00:00:23,725 is included in Coursera, 7 00:00:23,725 --> 00:00:25,930 it comes with all the included libraries and 8 00:00:25,930 --> 00:00:29,035 packages necessary to run the lessons in this class. 9 00:00:29,035 --> 00:00:30,640 Some people may prefer to 10 00:00:30,640 --> 00:00:32,460 run the files on your local computer. 11 00:00:32,460 --> 00:00:34,375 Today, we'll go over the steps 12 00:00:34,375 --> 00:00:36,940 and help you do that in this video. 13 00:00:36,940 --> 00:00:38,740 The only prerequisite for 14 00:00:38,740 --> 00:00:40,450 this tutorial are computer running 15 00:00:40,450 --> 00:00:42,910 Mac OS with administrative access 16 00:00:42,910 --> 00:00:44,540 that's connected to the Internet. 17 00:00:44,540 --> 00:00:46,180 We'll be completing the installation 18 00:00:46,180 --> 00:00:47,230 using the command line, 19 00:00:47,230 --> 00:00:48,310 which is a way to pass 20 00:00:48,310 --> 00:00:51,205 instructions to your computer using text. 21 00:00:51,205 --> 00:00:53,515 The command line is also known as a shell, 22 00:00:53,515 --> 00:00:55,765 and it's a powerful tool for modifying, 23 00:00:55,765 --> 00:00:59,390 automating, and organizing tasks on your computer. 24 00:00:59,390 --> 00:01:01,270 On Mac computers, we use 25 00:01:01,270 --> 00:01:02,830 the terminal application to 26 00:01:02,830 --> 00:01:04,630 access the command line interface. 27 00:01:04,630 --> 00:01:07,300 You can find terminal by opening finder, 28 00:01:07,300 --> 00:01:08,860 and navigating to terminal and 29 00:01:08,860 --> 00:01:11,725 the utility folder within the applications folder. 30 00:01:11,725 --> 00:01:14,620 In order to download and manage libraries, 31 00:01:14,620 --> 00:01:16,555 we'll need to download a package manager. 32 00:01:16,555 --> 00:01:18,310 A package manager is a set of 33 00:01:18,310 --> 00:01:20,050 software tools that automate 34 00:01:20,050 --> 00:01:21,730 complex installation processes on 35 00:01:21,730 --> 00:01:23,685 your computer which include downloading, 36 00:01:23,685 --> 00:01:26,865 upgrading, and configuring, and removing software. 37 00:01:26,865 --> 00:01:29,600 The most robust and common package manager 38 00:01:29,600 --> 00:01:31,565 for Mac OS is Homebrew, 39 00:01:31,565 --> 00:01:33,700 which we'll be using in this guide. 40 00:01:33,700 --> 00:01:35,315 Homebrew is a free and 41 00:01:35,315 --> 00:01:37,355 open source package managing system 42 00:01:37,355 --> 00:01:39,050 that makes the installation process 43 00:01:39,050 --> 00:01:41,135 on Mac computers pain-free. 44 00:01:41,135 --> 00:01:43,100 To install Homebrew, copy 45 00:01:43,100 --> 00:01:44,420 the following command and paste it 46 00:01:44,420 --> 00:01:46,180 in the terminal as such. 47 00:01:46,180 --> 00:01:49,065 Will go ahead and copy this link, 48 00:01:49,065 --> 00:01:52,120 navigate to our terminal, 49 00:01:52,520 --> 00:01:58,210 Control click, paste, and enter. 50 00:01:58,210 --> 00:02:00,530 You'll see a script 51 00:02:00,530 --> 00:02:02,540 asking for permissions download and we'll go ahead and 52 00:02:02,540 --> 00:02:04,520 press "Return," and then 53 00:02:04,520 --> 00:02:07,380 you'll see it download and install Homebrew. 54 00:02:10,940 --> 00:02:15,485 So, Homebrew is software programmed in the language Ruby. 55 00:02:15,485 --> 00:02:17,270 The installation works by modifying 56 00:02:17,270 --> 00:02:18,635 your computer's Ruby path, 57 00:02:18,635 --> 00:02:21,755 meaning where Ruby is installed on your computer. 58 00:02:21,755 --> 00:02:23,450 You'll need to confirm the download 59 00:02:23,450 --> 00:02:25,040 and enter your computer's password. 60 00:02:25,040 --> 00:02:27,170 Note that your keystrokes will not display in 61 00:02:27,170 --> 00:02:28,400 the terminal window when you're entering 62 00:02:28,400 --> 00:02:29,980 your password for security reasons. 63 00:02:29,980 --> 00:02:32,690 So, simply press "Enter" when finished typing 64 00:02:32,690 --> 00:02:34,580 your password and follow the instructions and 65 00:02:34,580 --> 00:02:37,270 terminal to finish the installation. 66 00:02:37,270 --> 00:02:40,760 Once that's finished, you can check if Homebrew installed 67 00:02:40,760 --> 00:02:42,140 successfully by typing 68 00:02:42,140 --> 00:02:44,060 the following command in your terminal. 69 00:02:44,060 --> 00:02:45,995 Just brew doctor. 70 00:02:45,995 --> 00:02:48,305 So we'll go ahead and copy that, 71 00:02:48,305 --> 00:02:51,715 go back and paste it, 72 00:02:51,715 --> 00:02:55,535 and we see that our system is ready to brew. 73 00:02:55,535 --> 00:02:58,415 Once Homebrew is finished installing, 74 00:02:58,415 --> 00:03:00,050 we can download Python. 75 00:03:00,050 --> 00:03:02,330 Homebrew comes included with a ton of 76 00:03:02,330 --> 00:03:04,595 packages available for easy installation. 77 00:03:04,595 --> 00:03:06,470 You can search for libraries to install 78 00:03:06,470 --> 00:03:08,465 using the brew search command. 79 00:03:08,465 --> 00:03:11,785 Feel free to browse Homebrew's packages on your own time. 80 00:03:11,785 --> 00:03:13,970 Now, we can go ahead and install Python 81 00:03:13,970 --> 00:03:16,640 3 using the following command and terminal. 82 00:03:16,640 --> 00:03:18,455 Brew install Python 3. 83 00:03:18,455 --> 00:03:21,150 So again, we'll go over copy that, 84 00:03:21,700 --> 00:03:26,545 Control click and paste it, and press "Enter." 85 00:03:26,545 --> 00:03:29,750 While Python 3 is already installed on this computer 86 00:03:29,750 --> 00:03:31,850 you'll see a few different instructions 87 00:03:31,850 --> 00:03:33,410 in your computer's terminal. 88 00:03:33,410 --> 00:03:35,120 As you can see on our computer it 89 00:03:35,120 --> 00:03:36,680 says we're already installed and up-to-date. 90 00:03:36,680 --> 00:03:38,600 But if you just follow the instructions in your terminal 91 00:03:38,600 --> 00:03:41,400 your Python will install correctly. 92 00:03:41,450 --> 00:03:44,240 Upon entering that command the terminal should 93 00:03:44,240 --> 00:03:46,655 be flooded with information about the download. 94 00:03:46,655 --> 00:03:48,440 In addition to Python 3, 95 00:03:48,440 --> 00:03:50,005 Homebrew will install PIP, 96 00:03:50,005 --> 00:03:51,710 setup tools, and a wheel. 97 00:03:51,710 --> 00:03:54,905 These are all libraries and packages for Python. 98 00:03:54,905 --> 00:03:58,010 Pip assists Homebrew and Python package management. 99 00:03:58,010 --> 00:04:00,530 We'll be using Pip momentarily to 100 00:04:00,530 --> 00:04:01,895 download the Python packages 101 00:04:01,895 --> 00:04:04,235 we'll be using in this module. 102 00:04:04,235 --> 00:04:07,145 We can check the version of Python we have 103 00:04:07,145 --> 00:04:10,560 using the following command Python version. 104 00:04:13,400 --> 00:04:17,570 As we see we are working with Python 2.7.1. 105 00:04:17,570 --> 00:04:20,630 While this is an older version of Mac OS, 106 00:04:20,630 --> 00:04:24,755 we do recommend using Python 3 to download. 107 00:04:24,755 --> 00:04:27,710 To update the version of Python on your computer, 108 00:04:27,710 --> 00:04:29,735 we first recommend updating Homebrew. 109 00:04:29,735 --> 00:04:31,740 You can do so with the following commands; 110 00:04:31,740 --> 00:04:33,920 brew update, and as we 111 00:04:33,920 --> 00:04:36,485 can see Homebrew is already up to date on our computer. 112 00:04:36,485 --> 00:04:39,545 Finally, brew upgrade Python 3. 113 00:04:39,545 --> 00:04:43,940 Great. Now we can see that Python 3.7 is installed. 114 00:04:43,940 --> 00:04:46,670 Now that we have Homebrew and Python installed, 115 00:04:46,670 --> 00:04:48,715 let's talk about Virtual Environments. 116 00:04:48,715 --> 00:04:51,230 Virtual Environments allow developers have 117 00:04:51,230 --> 00:04:54,080 separate spaces for different programming projects, 118 00:04:54,080 --> 00:04:56,120 ensuring that the downloaded packages of 119 00:04:56,120 --> 00:04:59,845 one project don't inadvertently effect another projects. 120 00:04:59,845 --> 00:05:02,030 Using Virtual Environments can prevent 121 00:05:02,030 --> 00:05:04,190 a lot of compilation issues, 122 00:05:04,190 --> 00:05:05,930 and it can also give us more control 123 00:05:05,930 --> 00:05:07,835 over our Python projects. 124 00:05:07,835 --> 00:05:10,040 It's best practice to create 125 00:05:10,040 --> 00:05:12,935 a programming environment for each programming project, 126 00:05:12,935 --> 00:05:15,440 as you can create as many of them as you like. 127 00:05:15,440 --> 00:05:17,665 Let's go ahead and create a Virtual Environment 128 00:05:17,665 --> 00:05:20,055 for this class Py3. 129 00:05:20,055 --> 00:05:21,860 First, we'll have to create 130 00:05:21,860 --> 00:05:24,335 a home directory to house the files and for this course. 131 00:05:24,335 --> 00:05:25,880 For this tutorial we'll put it 132 00:05:25,880 --> 00:05:27,395 in a folder on our desktop, 133 00:05:27,395 --> 00:05:30,415 although for you, you can put it wherever you like. 134 00:05:30,415 --> 00:05:32,625 In terminal type "cd ~", 135 00:05:32,625 --> 00:05:39,805 and that takes us to our home directory. 136 00:05:39,805 --> 00:05:41,500 Then we'll type in "cd 137 00:05:41,500 --> 00:05:44,575 desktop," and then we type the command 138 00:05:44,575 --> 00:05:51,875 "mkdir," and the name of your folder which we'll use Py3. 139 00:05:51,875 --> 00:05:54,610 We'll navigate into this folder using 140 00:05:54,610 --> 00:05:57,710 the change directory or cd command. 141 00:05:59,220 --> 00:06:01,840 Now that we're in our class directory, 142 00:06:01,840 --> 00:06:03,820 we can create our Virtual Environment 143 00:06:03,820 --> 00:06:06,020 simply by typing this command. 144 00:06:06,020 --> 00:06:08,140 In this command, the 3.7 145 00:06:08,140 --> 00:06:10,300 corresponds to the version of Python, 146 00:06:10,300 --> 00:06:12,880 and Py3env is the name of our environment. 147 00:06:12,880 --> 00:06:15,175 This command creates a new directory 148 00:06:15,175 --> 00:06:17,185 inside of our Py3 home folder, 149 00:06:17,185 --> 00:06:19,115 that houses a few files that allow 150 00:06:19,115 --> 00:06:21,365 our Virtual Environment to run correctly, 151 00:06:21,365 --> 00:06:23,390 isolating the project files so that they 152 00:06:23,390 --> 00:06:26,120 don't mix with this system files on our computer. 153 00:06:26,120 --> 00:06:29,435 The most important of these is the live subdirectory, 154 00:06:29,435 --> 00:06:32,465 which starts out empty but will at the end of this lesson 155 00:06:32,465 --> 00:06:34,340 hold the data for all the libraries 156 00:06:34,340 --> 00:06:36,650 we install in this environment. 157 00:06:36,650 --> 00:06:40,130 To use the environment we created we need to activate it. 158 00:06:40,130 --> 00:06:43,980 We do this by invoking the activate script and terminal. 159 00:06:48,680 --> 00:06:52,125 Wonderful. You know your Virtual Environment 160 00:06:52,125 --> 00:06:54,005 is activated when you see 161 00:06:54,005 --> 00:06:55,970 the name of your environment in parentheses 162 00:06:55,970 --> 00:06:59,320 before the terminal commands in the application. 163 00:06:59,320 --> 00:07:01,610 Now that we've created and 164 00:07:01,610 --> 00:07:03,515 activated our Virtual Environment, 165 00:07:03,515 --> 00:07:06,290 let's install the packages we'll need for the course. 166 00:07:06,290 --> 00:07:09,439 We'll describe more about what these packages do, 167 00:07:09,439 --> 00:07:11,705 and how to use them in different lessons. 168 00:07:11,705 --> 00:07:14,700 For now, just run the following commands one at 169 00:07:14,700 --> 00:07:16,800 a time in your Py3 folder 170 00:07:16,800 --> 00:07:18,995 with your Virtual Environment activated. 171 00:07:18,995 --> 00:07:20,740 Due to the power of editing, 172 00:07:20,740 --> 00:07:23,300 we're going to speed through this installation process. 173 00:07:23,300 --> 00:07:25,040 But understand that these packages may take 174 00:07:25,040 --> 00:07:28,100 some time to install, so be patient with them. 175 00:07:28,100 --> 00:07:31,760 Pip install pillow, tesseract, 176 00:07:31,760 --> 00:07:37,335 pytesseract, numpy, matplotlib, and opencv-python. 177 00:07:37,335 --> 00:07:39,265 With all the libraries 178 00:07:39,265 --> 00:07:41,510 downloaded we're nearly ready to go. 179 00:07:41,510 --> 00:07:43,775 We just need to get our files ready to run. 180 00:07:43,775 --> 00:07:46,500 Let's navigate to the Py3 Coursera course, 181 00:07:46,500 --> 00:07:48,350 download the Jupyter Notebook files with 182 00:07:48,350 --> 00:07:50,840 the ipynb extensions, 183 00:07:50,840 --> 00:07:52,565 and their accompanying data files, 184 00:07:52,565 --> 00:07:55,880 and put those into the Py3 directory on our own computer. 185 00:07:55,880 --> 00:07:58,310 To run these files, simply navigate to 186 00:07:58,310 --> 00:08:01,920 our folder in terminal and type "jupyter notebook" 187 00:08:09,700 --> 00:08:13,160 There you should see a folder for your files, 188 00:08:13,160 --> 00:08:14,570 and you'll be all ready to go and 189 00:08:14,570 --> 00:08:16,235 run these files within Jupyter. 190 00:08:16,235 --> 00:08:19,620 Thank you so much, and have fun with this course.