1 00:00:08,659 --> 00:00:13,852 Hi everyone, my name is Daniel Schorin and I'm a student assistant in this class. 2 00:00:13,852 --> 00:00:18,214 Today we'll be going over how to set up your local programming environment 3 00:00:18,214 --> 00:00:19,608 on a Windows computer. 4 00:00:19,608 --> 00:00:24,189 We'll go through and install all the libraries, packages, and 5 00:00:24,189 --> 00:00:28,034 software you'll need to run the files in this course. 6 00:00:28,034 --> 00:00:31,651 Well, the Jupyter console and the Coursera module, comes included with 7 00:00:31,651 --> 00:00:35,572 all of the libraries and packages you'll need to run the lessons in this class. 8 00:00:35,572 --> 00:00:39,482 Some people may prefer to do that on your own computer. 9 00:00:39,482 --> 00:00:43,529 The only prerequisites for this tutorial are computer running Windows 10 00:00:43,529 --> 00:00:47,312 with administrative access, that is connected to the internet. 11 00:00:47,312 --> 00:00:50,158 We'll be completing the installation using the command line. 12 00:00:50,158 --> 00:00:53,952 It's just a way to pass instructions to your computer using text. 13 00:00:53,952 --> 00:00:56,378 The command line is also known as a shell. 14 00:00:56,378 --> 00:01:00,845 It is a powerful tool for modifying, automating, and 15 00:01:00,845 --> 00:01:03,865 organizing tasks on your computer. 16 00:01:03,865 --> 00:01:08,209 Before we get too into the command line, let's first install Python. 17 00:01:08,209 --> 00:01:17,431 Navigate to this URL, https://www.python.org/downloads/windows, 18 00:01:17,431 --> 00:01:21,368 and download the latest version. 19 00:01:21,368 --> 00:01:26,046 At the time of this video recording, that's python 3.7.3. 20 00:01:26,046 --> 00:01:30,378 This downloads an installer which will automatically configure the paths and 21 00:01:30,378 --> 00:01:34,710 dependencies, along with the programming language to be interpreted by your 22 00:01:34,710 --> 00:01:35,382 computer. 23 00:01:35,382 --> 00:01:38,472 Follow the instructions and you'll be good to go. 24 00:01:40,015 --> 00:01:43,390 Python automatically comes with a package called PIP, 25 00:01:43,390 --> 00:01:46,633 which allows you to install libraries super easily. 26 00:01:46,633 --> 00:01:49,716 We'll touch more on PIP in just a little bit. 27 00:01:49,716 --> 00:01:54,337 In order to download and manage libraries, we'll need to download a package manager. 28 00:01:54,337 --> 00:01:57,650 Package manager is a set of software tools that automate 29 00:01:57,650 --> 00:02:01,529 complex installation processes, which include downloading, 30 00:02:01,529 --> 00:02:04,711 upgrading, configuring, and removing software. 31 00:02:04,711 --> 00:02:08,381 Their most robust and common package manager for 32 00:02:08,381 --> 00:02:12,865 Windows is Anaconda, which we'll be using in this guide. 33 00:02:12,865 --> 00:02:17,305 Anaconda is a free and open source package, an environment management system 34 00:02:17,305 --> 00:02:20,545 that makes installing software on Windows pain-free. 35 00:02:20,545 --> 00:02:24,536 Additionally, Anaconda is a Python data science distribution. 36 00:02:24,536 --> 00:02:28,232 And it comes loaded with lots of useful libraries for data mining, 37 00:02:28,232 --> 00:02:31,341 machine learning, and statistics programming work. 38 00:02:31,341 --> 00:02:33,847 If you are interested in using these libraries, 39 00:02:33,847 --> 00:02:37,697 be sure to check out the University of Michigan's applied data science and 40 00:02:37,697 --> 00:02:40,705 Python programming course on Coursera after this class. 41 00:02:40,705 --> 00:02:43,943 To download Anaconda, go into your web browser and 42 00:02:43,943 --> 00:02:47,486 navigate to www.anaconda.com/distribution, and 43 00:02:47,486 --> 00:02:52,854 download the package manager corresponding to the Python version you downloaded. 44 00:02:52,854 --> 00:02:55,978 This one's another installer program similar to the one used for 45 00:02:55,978 --> 00:02:57,296 the Python installation. 46 00:02:57,296 --> 00:02:58,932 Follow the instructions, 47 00:02:58,932 --> 00:03:02,852 download it to the default location, and you'll be ready to go. 48 00:03:02,852 --> 00:03:08,507 If you already have Anaconda installed on your computer, you can update it to 49 00:03:08,507 --> 00:03:14,435 the latest version by typing conda update conda in your command line interface. 50 00:03:14,435 --> 00:03:16,801 Now that we have our package manager installed, 51 00:03:16,801 --> 00:03:18,888 let's talk about virtual environments. 52 00:03:18,888 --> 00:03:22,536 Virtual environments allow developers to have separate space for 53 00:03:22,536 --> 00:03:26,834 programming projects, ensuring that the dependencies of one project don't 54 00:03:26,834 --> 00:03:29,190 inadvertently affect another projects. 55 00:03:29,190 --> 00:03:32,876 Using virtual environments can prevent a lot of compilation issues. 56 00:03:32,876 --> 00:03:36,344 As well as giving more control over our Python projects. 57 00:03:36,344 --> 00:03:39,800 It's a best practice to create a program environment for 58 00:03:39,800 --> 00:03:44,200 each programming project, as you can create as many as them as you like. 59 00:03:44,200 --> 00:03:48,530 Let's go a head and create a virtual environment for this class pie three. 60 00:03:48,530 --> 00:03:52,098 To do this we'll use Anaconda's built in virtual environment 61 00:03:52,098 --> 00:03:54,329 capabilities using the command line. 62 00:03:54,329 --> 00:03:58,315 On Windows computers, we can use the command line application to access 63 00:03:58,315 --> 00:04:03,039 the command line interface, which can run scripts, download software, and more. 64 00:04:03,039 --> 00:04:05,949 You can find the command line by opening the Start menu and 65 00:04:05,949 --> 00:04:09,414 scrolling through your applications, or by using the search bar. 66 00:04:09,414 --> 00:04:12,727 Once you have your command line opened, let's create a home directory for 67 00:04:12,727 --> 00:04:13,839 the files in this class. 68 00:04:13,839 --> 00:04:17,357 For this tutorial, we'll place it in a folder on your desktop although you can 69 00:04:17,357 --> 00:04:18,703 put it wherever you'd like. 70 00:04:18,703 --> 00:04:23,559 Type cd ~. 71 00:04:23,559 --> 00:04:28,248 That'll just take you back to your home directory, and then type cd desktop. 72 00:04:28,248 --> 00:04:33,230 Cd stands for change directory, that'll help us change the directories and 73 00:04:33,230 --> 00:04:36,305 folders as we navigate using the command line. 74 00:04:36,305 --> 00:04:40,061 So cd desktop helps us navigate to our desktop. 75 00:04:40,061 --> 00:04:45,977 And then we're going to make a folder using the command make directory or 76 00:04:45,977 --> 00:04:48,390 make dir, M-K-D-I-R. 77 00:04:48,390 --> 00:04:51,744 And then the name of our home folder for this class, and for 78 00:04:51,744 --> 00:04:57,266 this we use pie 3 Now that we've had that folder created, 79 00:04:57,266 --> 00:05:00,465 we'll go into that folder using the change directory command. 80 00:05:00,465 --> 00:05:02,633 Now that we're in our class directory, 81 00:05:02,633 --> 00:05:06,478 we'll create our virtual environment simply by typing this command. 82 00:05:06,478 --> 00:05:14,706 Conda create -n py3env python=3.7.2 anaconda. 83 00:05:14,706 --> 00:05:18,266 Where py3env is the name of our virtual environment, and 84 00:05:18,266 --> 00:05:22,781 the Python version corresponds with the Python version you downloaded. 85 00:05:22,781 --> 00:05:26,775 You can check the Python version by typing python --version. 86 00:05:31,015 --> 00:05:35,505 Here on this computer we're using Python 3.5. 87 00:05:35,505 --> 00:05:38,733 So that we've created our virtual environment we can activate it using 88 00:05:38,733 --> 00:05:39,878 the following command. 89 00:05:39,878 --> 00:05:45,925 Just simply source activate py3env, where py3env is the name of our environment. 90 00:05:45,925 --> 00:05:46,877 As you can see, 91 00:05:46,877 --> 00:05:52,170 the Windows is built-in command prompt is having a hard time working with Anaconda. 92 00:05:52,170 --> 00:05:53,451 To work around this, 93 00:05:53,451 --> 00:05:57,517 we're going to use a command line interface program called Git bash. 94 00:05:57,517 --> 00:06:01,656 Git bash is a shell, which works on top of the command prompt to make it easier to 95 00:06:01,656 --> 00:06:05,509 download libraries and easier to work with your command line as a whole. 96 00:06:05,509 --> 00:06:08,525 To download Git bash, just Google search Git bash. 97 00:06:12,586 --> 00:06:15,730 Click on the downloads page. 98 00:06:15,730 --> 00:06:20,813 Click on your Windows operating system, and your download will start immediately. 99 00:06:20,813 --> 00:06:26,541 Follow the instructions on that download, and you'll be all set to use Git bash. 100 00:06:26,541 --> 00:06:34,065 We'll go to our main directory, go to our desktop, go to our py3 folder. 101 00:06:35,692 --> 00:06:40,473 And now, since we already created the environment using the command line 102 00:06:40,473 --> 00:06:43,017 interface from the windows computer, 103 00:06:43,017 --> 00:06:46,733 we'll go ahead and see if that's working with Git bash. 104 00:06:46,733 --> 00:06:54,348 So, we'll try source activate py3env, and wonderful. 105 00:06:54,348 --> 00:06:57,346 We're in our Python 3 virtual environment. 106 00:07:01,131 --> 00:07:05,390 You can tell that you are in your Python 3 environment if the name of 107 00:07:05,390 --> 00:07:08,981 your environment is in parentheses after any command. 108 00:07:08,981 --> 00:07:12,821 Now that we've created and activated our virtual environment, 109 00:07:12,821 --> 00:07:16,257 let's install the packages we'll need for this course. 110 00:07:16,257 --> 00:07:19,216 We'll describe more about what these packages do and 111 00:07:19,216 --> 00:07:21,328 how to use them in different lessons. 112 00:07:21,328 --> 00:07:24,541 For now, run the following commands one at a time, 113 00:07:24,541 --> 00:07:28,524 in your py3 folder with your virtual environment activated. 114 00:07:28,524 --> 00:07:32,345 Due to the power of editing, we're going to speed through the process of 115 00:07:32,345 --> 00:07:36,773 copying and pasting these downloads into your Git bash shell or command prompt. 116 00:07:36,773 --> 00:07:41,113 And additionally, on this computer, these packages were already installed, so 117 00:07:41,113 --> 00:07:45,146 don't be alarmed if you see different instructions in your command prompt. 118 00:07:45,146 --> 00:07:51,713 We'll install pip install pillow, Pip install pytesseract, 119 00:07:52,879 --> 00:07:58,457 Pip install numpy, pip install matplotlib, 120 00:07:58,457 --> 00:08:02,612 and pip install opencv-python. 121 00:08:02,612 --> 00:08:06,240 With all of your libraries downloaded, we're nearly ready to go. 122 00:08:06,240 --> 00:08:08,662 We just need to get our files ready to run. 123 00:08:08,662 --> 00:08:11,350 Let's navigate to the Py3 Coursera class. 124 00:08:11,350 --> 00:08:16,181 Download the Jupyter notebook files with their I, P, Y, and B extensions, and 125 00:08:16,181 --> 00:08:20,953 their accompanying data files into the Py3 directory on your local computer. 126 00:08:20,953 --> 00:08:25,687 To run these files, we'll simply navigate to our folder in the command line and 127 00:08:25,687 --> 00:08:27,180 type Jupyter notebook. 128 00:08:27,180 --> 00:08:30,604 As you can see, our notebook is up here all ready to go. 129 00:08:30,604 --> 00:08:33,400 If you can solve the files, they'll be ready for you to run. 130 00:08:33,400 --> 00:08:36,250 Thank you all so much have a ton of fun in this class.