Getting Started with Python in Visual Studio Code | Python with VSCode

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hey guys in this video I'm going to show you how you can get started with Python on your visual studio code editor using your Windows 10 operating system so let's get started so to start with you need to have Python installed on your Windows 10 operating system and also I'm hoping and expecting that you already have installed Visual Studio code on your Windows 10 operating system now to check where the Python is installed I am going to right click on my windows icon here and open the command prompt and here I'm going to just type Python and then space - - version and then press Enter and you can see I have Python three point seven point four installed on my Windows operating system so make sure that python is installed and also visual studio code is installed so you can see visual studio code is already installed so now the only thing remains is I need to open the Visual Studio code and create my project so to start with because this is a Python development kind of tutorial I'm going to open the command prompt and I want to show you some more things so you can go to your chosen directory let's say I want to just create a project inside my desktop directory so I'm going to just type desktop CD desktop and then I'm going to create a directory using mkdir command and then the name of your directory which you want to create so let's say I want to create a directory called books so I'm going to just give this command mkdir work which is going to create this directory in your desktop right so you can CD to your work directory so now you are inside your work directly in the terminal so you can directly open visual studio code inside this directory using this command code space dot so just keep this comma and then press Enter which is going to open visual studio code on the same directory you can see so now the work of this terminal is done so I'm going to just close this terminal so now we want to create some Python script and we want to run this python script using visual studio code and also we want to debug our python script using visual studio code so let's create a python file first of all so i'm going to just create a test dot py file and then press enter which is going to create this file and as soon as you create this file inside Visual Studio code straightaway this message will pop up which says the python extension is recommended for this file type so if you want to install it you can just click on the install button if you don't want to install it straight away from this message you can also go to this last option which is called the extensions and just click on this here also you can search for Python inside the search for box or you will see in the recommendation this Python plug-in also so for example I just type here Python and the first result here will be the Python plug-in extension you can also read more about this extension by clicking on this extension right so this is the same extension which is recommended by visual studio code to us which is this pop-up right so if you just click on the install button it's going to install the Python extension and you can see how many number of time it is downloaded it is downloaded about 62 million times so it's the most popular or one of the most popular extensions which is provided by Microsoft that's also important right so I'm going to just click on install button which is going to install this Python extension you can see some more extensions also here for example Python for visual studio code which is also relatively popular you can see 1 million downloads of this extension and you can see many more extensions when you just type here Python so for example Python preview or Python path so now you can see that this python extension is added to our Visual Studio code and at any time you can also uninstall this extension by clicking on the uninstall button so once this extension is installed just go to your Explorer once again I'm going to just close this page from here and now you can also see some tips and recommendations from your visual studio code editor which is to install pee violent extension so this time I'm going to just directly click on this install button which is going to install this pee violent extension on our Visual Studio code so you can see it's installing this package and you will also observe that this package is just a pip package and you can see this command is already given on your terminal which is PIP install a pee violent for this user so if you want to install pee violent manually you can also give this command using pip so you can just write pip install pee by length and this procedure is same as what Visual Studio code is doing for us right I'm going to just close this recommendation because we have already installed the python extension for the Visual Studio code and now you can see that the py length the extension is also installed so you can see this terminal is also available inside your Visual Studio code from where you can run your script directly so I'm going to just close this terminal for now and I'm going to show you how you can open it once again you can go to the view and then from here you can just click on the terminal which is going to open the terminal if you want to open multiple terminal you can just click on this plus button and you can see there are multiple terminals open which you can switch using this menu bar from here right so let's just create some code so I'm going to just define for example msg for a message is equal to hello world let's say we want to print hello world on the terminal and then inside this print function I'm going to just pass my MSG variable so once you have done writing your code you can right click on the same file and then you will see this option which says run Python in terminal which is going to run your python script inside your terminal so I'm going to just click on this option and you can see it runs this Python script using Python on your terminal and it prints hello world here so you can see this output hello world also if you want to increase the font size you can just go to file and then go to the Preferences here and then click on settings which is going to open this window and then you can go to the text editor here and then go to the font and I'm going to increase this font size to let's say 18 and then press ENTER which is going to increase this font size to 18 you can see the font size is now increased you can also do it let's say 20 which is going to make this font little bit more bigger so let me just close this window once again and let's concentrate on our Python script now let's try to do it manually we have just ran our script using just right clicking on the file and then choosing this option but you can run your python script using the command line simply so you can just write python and the name of your script which is a test in our case and because it's PS terminal which is a PowerShell terminal that's why it's adding this dot and this backslash here otherwise we could have just used test dot py also on your Linux operating system and it will run fine also so you can see the same result here also you can see on the left hand corner this Python version which is available for your visual studio code so you can see python 3.7 point for 64-bit version is used by Visual Studio code on our Windows 10 operating system so now let's try to debug our code so to debug our code we just need to give the breakpoint breakpoint you can give from here so just click on the Left bar here and then you can see the red dot that means we have set the breakpoint and then you can just go to the debug options and right now there is no configuration here so when you click on this spanner option you can see this round I can here you will be able to see the first option here it says python file so you can just click on this python file which is going to create this launch dot jason file inside your project so now you can see there is a folder which is created which is called dot vs code and inside this dot vs code your launch dot JSON file is there but let's not just concentrate on this launch dot JSON file yet we want to debug our code so we just want to click on the debug option and once you have clicked on the python file options you will be able to see python here or when you drop this menu you will be able to see python here once you have clicked this open launch date JSON file and then you can see this green button here so I'm going to just click on this green button which is going to start the debugging of the python script so debugger has been started and in some time you can see that our debugger is stopped at this breakpoint which we have set for our print function and on the left hand side you can see the local variables here so there is only one local variable which we have defined which was this message variable and also there are so many built-ins which are available inside your standard Python so those are also shown here if you want to watch any variable you can also write the name of that expression for example MSG and then I'm going to just press ENTER and it's going to give you the value of that expression so I have just added this expression and it shows me hello world also there is a call stake here and you can see the breakpoints here you can also see these button first button here is for the continue second is for step over third is for step into and the fourth button is for step out and this button is to restart your debugging and the last button is for stop your debugging so let's say I'm going to just click on continue button which is going to just continue the script after the breakpoint and it's going to show us this output once again when you run your debugger your debugger is going to stop at this breakpoint which you have set so this is how you can debug your code you can also restart your debugging by just pressing the restart button and it's going to restart your debugging so let's stop our debugging for now and let's go to our script once again now let's see how the intelligence work in your visual studio code for python so we have declared this variable called MSG when you write for example dot here you will be able to see bunch of functions which you can apply on your a string variable for example capitalized or all these functions which are available here so let's say we want to apply this lower function and when you try to complete this function using this parenthesis it's also going to show you what this function is going to do so it's going to return the copy of the string converted to the lowercase right so this is how you can use the intellisense if the intellisense is not working you just need to relaunch your Visual Studio codes because sometimes you need to restart your Visual Studio code on your Windows operating system after installing the extensions so we have installed the python extension and if you don't restart it sometime it's not going to work so try to restart your Visual Studio code and then try to use this intelligence and it's going to work most probably so this is how you can get started with python on your Visual Studio code editor inside your Windows 10 operating system I hope you have enjoyed this video and I will see you in the next video
Info
Channel: ProgrammingKnowledge
Views: 636,177
Rating: undefined out of 5
Keywords: Visual Studio, Visual Studio Code, windows 10, vs code, Python, Development, environment, How to Set Up Python, Python in Visual Studio Code, Python Development environment, Set Up, Install Python, Visual Studio Code for Windows 10, Python Development, Python with VSCode, VSCode, Python IDE, PyCharm, Visual Studio Code for Python, Debugging Python
Id: E9U-EBG8jVk
Channel Id: undefined
Length: 14min 38sec (878 seconds)
Published: Thu Sep 12 2019
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.