How to set up Python on Visual Studio Code in 2021

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hey there hope you're having a wonderful day in this video i'm going to show you how to set up python with visual studio code so most people like to use pycharm when they're writing python code or anaconda with spider i prefer visual studio code i think it's much easier to use and it's more convenient if you're working with other languages as well so first we want to install python so what i'm going to do first is go to terminal or command prompt and check which version i have so to do that i'll just type python dash dash version and you can see i am on 3.8.3 with python commands you can also just type pi instead of python it saves you four characters so pi dash dash version and we get the same thing if you do not have python on your machine for instance if i type python like this you might get something like this where it says python is not recognized as an internal or external command so this just means that you don't have python on your machine so let's install that so go to python.org go to downloads and click this right here for me it says download for windows because i'm using windows but for you if you're using a mac or linux then it will say download for mac or linux so click that okay so now we have it downloaded so click it to install it and then just click install now so after you have installed go to code.visualstudio.com make sure it's the blue one it says visual studio code not the purple one the blue one so for you it might say down for mac or linux for me it says download for windows so just click this button whatever it says and then now we can open it and you'll get this pop-up just accept agreement next you want to click create a desktop icon and then click next and then click install i already have it installed so i'm not going to click it but just click install and then afterwards you should see visual studio code on your desktop you can double click it or you can drag it to your taskbar if you are going to code frequently so just click that and you'll see we have uh this uh setup we're going to create file and click ctrl s to save it so i'm going to save it to my desktop let's name it test dot python so make sure you include the extension for python it's py or pi so let's save that and then here you can see your python file we can create another one so let's do test2 dot pi and here's our second file so make sure you include the extension and in file 1 or test.pi i'm going to put print this is file 1 and print let's say 50. so this is just outputting to the console or terminal and then for the other one i'm going to say print file 2 and let's print 100 okay so you can see both of them are created on our desktop we go on terminal and we type in python or pi and we go to the directory of our file so desktop slash test.pi and you see this is file150 and i can do test 2 and this is file 2 100 or you can just change directory to desktop and type pi test.pi or pythontest.pi either one works and we can do test2 as well so this is how you would run your uh python files but with visual studio code we have an editor so let's not do that we have our built-in terminal over here and we can just copy and paste the command we did so cd desktop and just do pi test.pi and you'll see this is file 150 okay but you might have noticed that i have this run button over here so i can just click this and it will execute that command for me so i don't have to type all that i just need to click this button you probably don't have this button so let's go install that so go to this block here extensions first thing you want to do is install python so search for python and look for the one by microsoft and click install and then afterwards look for code runner it's the one with this logo just click install and then after you install this you should have this run button over here and then now you can just click run code when you run your code it might not output to the terminal it might output to the visual studio built-in console the output console and the problem with this is this is a read-only console that means if you were to ask the user for an input you can't type anything in you can't type in any commands we want it we want to set it to the terminal so to change it to the terminal go to this gear icon click this icon and click settings and then scroll down until you see right here called actions on save click edit in settings.json and then what you want to do is you want to add this line i will copy and paste this into the description so code runner dot run in terminal set it to true and then afterwards when you hit the run button it should go to the terminal okay and another thing you can do is we can put these files in our folder so let's create a folder here new folder let's call it python files so i'm going to drag these two in here and then now i have two files in my python files folder i can just drag this onto the visual studio code icon and you can see over here i have these two files okay and if you don't want to do that if you have it somewhere else that is not on your desktop and you don't want to go through your directories to find it you can just use the terminal and just go cd so i'm already in the desktop but if you're not in the desktop just go cd desktop and then cd stands for change directory so cd to your folder so in my case it's python files and just type in code dot and then this will open up visual studio code okay so that's how you set up python with visual studio code if you enjoyed this video and it worked for you make sure to leave a like and subscribe for more updates on python tutorial videos and all that fun stuff all right thank you for watching and i'll see you later bye
Info
Channel: Kenny Yip Coding
Views: 33,928
Rating: undefined out of 5
Keywords: How to setup python on vscode, How to install python, install python on visual studio code, how to setup python on visual studio code, how to install python on visual studio code, set up python with visual studio code, python vscode, set up visual studio code, vscode, visual studio code python, vscode python setup, add run button in vscode, add run button in visual studio code, install visual studio code for python, how to install python in visual studio code, python vscode setup
Id: 9o4gDQvVkLU
Channel Id: undefined
Length: 6min 56sec (416 seconds)
Published: Wed May 19 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.