You MUST WATCH THIS before installing PYTHON. PLEASE DON'T MAKE this MISTAKE.

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
if you're about to install Python for the first time you're almost certainly gonna do it wrong and I want to help you with that so watch this video and I'll explain how to install Python properly using something called virtual environments now this is something that I definitely wish I'd known about when I started using Python because I installed Python you know in the traditional way I installed it from the python.org website which is how you should install it but there are a few things you need to know and virtual environments are incredibly useful but nobody tells you about them when you're a beginner so what happens is you install it everything seems to go well you have this system-wide installation of Python and you're learning how to use the language and it's all great and it all works and that's fantastic and then you start to want to do your own projects so you search for Python packages with the Python package manager and you start installing all sorts of Python packages you're probably never ever going to use but you install them all anyway and then you start building little mini projects and that works for a while and then you find that one project has a different set of dependencies ie needs different packages and modules to another project that you've done so you change you change the versions of the packages and the modules that you've got in order to accommodate the project that you're working on and lo and behold the previous projects that you've done they break so you install another version of Python and you add that to the path and then that seems to work but then none of your previous projects that you did work and and you get into a complete mess with it and and this is a thing now this actually happened and this is what I wanted to help you with so today we're gonna have a look at how to install Python properly and how to set up virtual environments so that you can have any number of projects and with you know all with their own dependencies and you won't get any conflicts so a virtual environment is like a little sandbox for your project you can set up a virtual environment you can install all the dependencies that that project needs you can you know install all of the modules and the packages that you need in the right version numbers in that little virtual environment but it's not system-wide it doesn't ever come into contact with any of the other dependencies that are needed for other projects that you've run in these virtual environments and so everything works very nicely and it's a really good way of setting up Python for the future as well because if you're planning to collaborate with people if you're going to work on projects and there are several people involved everybody needs the same version of Python they need the same installation they need the same dependencies you know on many different machines you know so that they can test that everything works and everything is compatible and and you're going to need to be able to use them so it's something you need to know about from the start which most beginner guides don't tell you about so let's look at how to do that now so what I'd like you to do is go to python.org and then to downloads and download the correct version of python for you currently as of today the latest version is three point eight point three so select that and download it that will take a little while to download and once you're done launch the setup application now don't touch anything just yet first of all I want you to notice here you have the option of adding Python three point a to the path now if you've already installed Python before if you have a version of python on your system i would recommend that you don't do that and in fact what i'd like you to do now is go to the command prompt and let's make a directory for python - well you know where we can put python now what we can put this downloads so we'll do it incidentally if you're looking to learn pipe and then i have a top rated python course over on you to me but link is in the description if you use that link you'll get a discount and so go over and check it out mkdir and let's call it pi the e offer PI version and we'll make that and also while we're here let's make a directory of where we're going to put our PI Python project and you'll see why shortly so we've now made those two directories or folders whatever you want to call them and let's have a look can we see them yes we can we've got PI V and pipe Roger that's great so let's minimize that now okay so let's go for a custom installation will customize installation and remember we're not going to tick this we don't want to add it to our path just yet in fact we're not going to add it to our path at all during this video although it's something that you can do later I just want to make sure you don't get any conflicts with anything that you may have already downloaded and installed so let's do that yeah we are going to install it to the location that we created previously so it's just to have a look let's go and what did we call it I think we called it pivert didn't we so we'll do that and and now let's create a Python 3 8 3 folder location so let's call it PI 3 8 3 ok so we'll click on install and that will take a little while while we're waiting for that to install and a minor so we have second friend a second fret first string a minor and then if you put that with F major which is the first finger third string first fret and the second finger first string second fret [Music] so anyway let's see if it's installed that so that's installed right we'll close that and now I want to go back to the command prompt let's just clear that now and give us some space and now we're going to go into the folder that we've created the Python projects folder so let's do that now where was it I think we called it pipe ROG and so we'll do that and what we're going to do now is we're going to create our virtual environment so remember a virtual environment is like a sandbox for a particular project where you don't have to worry about any compatibility issues or conflicts with any other versions or projects that you might be running on your system and the way we set this up in Windows it's a little different in Mac for Mac or Linux but in Windows the command is first of all you put the path to the Python interpreter that you want to use and then you type - M V env for virtual environment and then you put the name of the virtual environment that you want to create or the path followed by the name but since we're going to create it in this Python project folder we won't have to worry about putting the path so I'll show you what I mean so first of all we want to put the path to our Python interpreter now if we remember that should be users Giles and then I think it was PI V and then we need the I think it was PI was it PI three eight three yes I think it was and then we need the Python executable file so that's plaything there and then - M and then V env because we want to create a virtual environment and we're just gonna call this virtual environment my e NV so let's do that and it'll take a little while we haven't got any error messages so it looks like it's working and now our virtual environment that's called my EMV is going to be set up and let's just wait for that to happen let's take a look at it now so my what first of all I tell you what let's just check that it's there so let's have a look inside this folder now and you can see here that we've got my EMV so let's just clear that and let's take a look at it now by doing tree and this shows us what we've got here so this you can see is now our Python installation we've got site packages now normally these site packages they're system-wide but this site packages here is just for this virtual environment which means we're not going to get any conflicts now let's move down now let's activate this environment now the way we do that in Windows it's slightly different on a Mac or Linux but in Windows you do it like this so we are in the right folder and you type the name of the virtual environment follow my script and then activate so we activate it and now you can see we have here before the prompt we have the name of the virtual environment and that means that we are now within this virtual environment so let's have a look and see if we can get Python running on here and we have this is the interactive Python here and you can see we're running the three point eight point three which is the Python interpreter that we pointed to when we set up the virtual environment and now let's just see if it works I mean it should do shouldn't it say let's print hello world and we get hallo wealth and now let's try to import numpy now this probably won't work because we haven't installed numpy and it doesn't work so we'll exit out of that and let's install numpy we're going to install them by using pip so if we do pip install and people is just the Python packet matter package manager and you know you can use that to install various Python packages so we're going to install numpy and you can see that it's now installing them pipe now while this one's installing how about we learn how to play G which is that so first and second finger on the second fret first finger on the second string second finger on the fourth string and then third finger on the third string of the third fret and you get okay so we put a warning there that we're using the old version an older version of pip and there is a newer one available but now if we run Python we can check that we have numpy whoops I've imported it as MP a slight typo there but we have numpy and it is working so let's leave that and so that is how you set up a virtual environment and for every separate project that you do you should set up its own virtual environment and that way you won't get any conflicts now you can see we're in this virtual environment here if we want to get out of this now we just type deactivate and that takes us back you can see the prompts now changed so that is how to setup and use virtual environments make sure you use them they will be incredibly useful to you and before I go I just wanted to point out you may have noticed but you might not have is there just in the background there I'm a physicist and so I just wanted to introduce a little bit of physics you know we didn't get a chance to talk about visit physics here in the background there we've got Maxwell's equations you may know all about Maxwell's equations if you don't go and check them out they absolutely incredible they're wonderful once you know about them the world will never be the same again I'll see you next time
Info
Channel: Python Programmer
Views: 382,130
Rating: undefined out of 5
Keywords: learn python, python, installing python, virtual environments, venv, python version, python for beginners
Id: 28eLP22SMTA
Channel Id: undefined
Length: 12min 5sec (725 seconds)
Published: Wed Jun 17 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.