Summarize the following content in 5-10 bullet points with timestamp if it's transcript. Title: "Visual Studio Code (Windows) - Setting up a Python Development Environment and Complete Overview" Transcript: "(00:00) hey there how's it going everybody in this video we're gonna be learning how to install Visual Studio code and set up a Python development environment we're also going to go over the different features of this editor and see why it's so nice for Python development so we'll cover how to easily switch between editors how to debug applications how git integration works look at unit testing capabilities and a few other things so I've had a ton of comments and requests to cover vs code and it just seems like so many people are switching (00:26) over to it I don't know how many of you all listen to talk Python podcasts with Michael Kennedy but at the end of every show he always asks us guess what editor or IDE they prefer to use and it used to be pretty mixed but now I just feel like I hear vs code so often on there that I figured I had to take some time out to try this and I've got to say so far I'm really impressed with this editor now I wouldn't doubt if you all see me using this from here on out in my videos so with that said let's go ahead and get (00:53) started and see how to set this up and I'll show you what I like so much about this now I ran into some differences between how this works on Windows and Mac so I decided to just make one video specifically for Windows and one specifically for Mac so this video will be covering how to use vs code on Windows but if you're using a Mac then I'll be sure to leave a link to that video in a description section below so firs t of all let's go ahead and install Visual Studio code so I've got their website pulled open here in my browser (01:20) and that is at code Visual Studio com now Visual Studio code is different from Visual Studio which is a full on IDE vs code is a lighter-weight editor that can be extended with plugins for whatever we need so be sure to search for Visual Studio code and not just Visual Studio I'll also have a link to this page in the description section below now vs code is free so we don't nee d to buy anything we just need to download it and install it so I'm just going to download it from the website here so I'll click on download and then it (01:53) choose your operating system I'm on a Windows here and now this should download automatically ok so once that is downloaded I'm just going to run that executable and this is just like any other software installation wizard we'll have to accept some terms here pick our install location I'll go ahead and create a desktop icon for this as well and let's just continue on and finally I will install and once that's installed then I will open up visual studio code okay so now that that's finished I'm just going to check (02:26) this here that says launch Visual Studio code and finish that and now it should launch vs code for the first time here so this might take a sec to pop up okay so when we first run vs code it's going to open they're getting started page in the browser and also it's going to show us their welcome screen here wit e here is the Explorer and if we click on that then this is where we can open our directories and files we don't have anything open right now but we have the option to open a project folder and we'll do that here in just a second so the second option here this is for search so this is where we can do our (03:59) finds and replace and we can do these within multiple files and the third icon here is the git integration which is the source control and we're gonna take a look at this in a bit and se within the extensions here but I'm just going to close that for now and now we're going to look at the popular extensions here so the extension that we're really after right now is this Python extension and this is the most popular extension on vs code by far so if I sort the extensions by popularity so right now if we go to show popular extensions then it's already sorted by install count but we can also sort by rating a name if we wanted to as well so (06:09) we can see here at the top we have m I'm going to select deselect to show the welcome page on (07:48) startup and now I'm going to open up my python script okay so we get a few pop-ups down here this one says that we can change our Python interpreter and this one says that we don't have a linter installed now I'm probably going to get these pop-ups a good bit but I'm just going to ignore them for now and we will take a further look at these whenever we actually do linting but for now I'm gonna have to keep just exiting those out ee how to make it more simple in just a bit but for now if we look at my output down here then we can see that I'm using Python 3 7 that are printed out right there and then it prints out the location where that is here on my machine and also it (10:02) printed out those greetings ok so what if we wanted to change our Python interpreter so there are a couple of different ways that we can do this so if we look at the blue bar at the bottom of the page then in the bottom left it shows us which Pyt e that now when I changed my interpreter you may or may not have noticed that vs code created a folder inside of my project directory here called dot vs code and that directory has a Settings dot JSON file so these are settings for our specific current workspace so let me open this up and we can see that it set our Python a path within the settings JSON file but what if we wanted to use a certain Python interpreter by default (12:19) for every project because right now this is just this specific -dawn now somebody has actually put together a pre-dawn 4 vs code as well (14:00) and I'm glad that they did because I like that color theme so that's what I'm going to use and it's this one here pre-dawn theme kit this pre-dawn Twilight I'm not sure what that is but this is the one that looks like the sublime text version so I'm going to install that and then click on that to use pre-dawn now if I go back to my script then we can see for those of you have seen my videos before this likely looks I like this one because it gives a nice indicator of closed and open folders here on within your file explorer over here okay so I think those setting changes look pretty good for both our color theme and for our file (16:16) icons so right now we're actually implicitly changing our global user settings by changing our color themes and all of that but there are a ton of other settings that we can change that we haven't seen yet so if we want to see all of the settings that we can change then we e changed the zoom level this startup editor is because I said that I don't want to see the welcome screen when I log in we have the color theme here and the icon theme here as well now I have some other preferred settings that I'll show in just a bit now I do wish that they showed the default settings by default when we open up our settings as well because I feel like someone who's new to (18:18) v/s code might not know what settings they can and can't change so it'd be nice to see those defaul n we can always click on this pencil (19:59) icon over here and the gutter that says edit when I click on that it gives us the options that we can use so we can either use UI or JSON so that is a nice touch there and it says I have to save and retry in order to save that so I changed that to JSON now I'm also going to let's see come down here a little bit and I want open default settings set the true as well we can see that the comment here says controls whether opening settings also opens an ed e into my settings and now I want to put the full path to the version of Python that I want to use by default so in order to do this I think the best way to grab this would just be to open (22:21) my integrated terminal here and you can do that with control tilde and now I'm gonna do a command of where Python and this should show me okay so that didn't work there let me see if the Python command is running there okay so that is so I can do import sis and then do sis dot executable and that will that is because we are zoomed in to the here so that size 16 font actually looks pretty large the reason we're zoomed in is so that we can see everything else here in the editor like the sidebar and things like that now on your machine you might not need to zoom in the only reason I'm doing that is because I'm recording this video and I want (24:46) everybody to be able to see now I'm also using a source code Pro here as my font for the editor and for the debug terminal now if you want to use th 23) this so I'll be sure to leave a link to that in the description section below as well if anyone is interested but basically we can just say Python whoops let me spell that right Python - M and that will run a module and the module we want to run is ve and V and now we can pass in our arguments to that module and the arguments we want our the virtual environment name and the virtual environment name I'm just going to call ve and V as well so if I run that then it might take a second to create tivate that environment and all new terminal sessions as well so I think that's a really nice feature so if I open up terminal here let me close down the one I currently have by (28:37) clicking this trashcan and kill terminal let me open up another one and when I open that we can see that it automatically came in and ran that activate script on that virtual environment so if I clear my screen here we can tell that the virtual environment is active because we have V and V over here in a so if we e request library itself so we can see exactly how that method was written so I think that's a very nice feature now if we don't want to completely open up that file where that method exists then we can click on peak definition and that will just show us a little peak here so we can see the get method here within this little window but when we close that or write back to (31:02) our file so I think that intellisense is very useful for giving you information like that so let me actually go to my (32:57) auto pep eighth installed would you like to install that as your formatter and it also suggests some other popular formatters here too such as black and why a PF now I'm going to use black here but you can use auto pepe if you'd like I actually don't really know the differences between those two but I saw on Kenneth writes his blog that he was using black so I'm gonna give it a shot and see if I notice any differences or not okay so now with that formatter installed then we should be abl l of these here so format on paste format on save I want format on save so anytime I save it'll just auto format my code for me and that's a setting that I think is very (35:24) useful so that we don't have to keep manually doing that and the auto formatting and vs code really is great not only does it do Python like we have set up here but it will also auto format for JSON and other languages as well and those are all things that usually require additional packages with editors like sublime tex ur own so if this pop-up wasn't open here I'm just going to close it one more time then we can search using our command palette I'm just going to type in linting and now I'm gonna choose run linting when I try to run linting it's going to pop up with that pop-up so now I'm going to install that and it'll install pilant (37:47) and you can use other linters as well but I think that pilant is a and nice default linter to use I haven't really tried any of the other ones but pilant has been good for hen that might be a mistake so usually we don't want those so with that pointed out I'm just going to get rid of that to clean up the code and there we go okay so now let me show you an extension that I like to use that makes running Python code a bit easier so so far we've been right-clicking and selecting run code in terminal every time we want to run our Python code but I'm not the biggest fan of that I'd rather have an easy keyboard shortcut (39:58) that does this for us and also I don't lik ht here so it says that we're using Python 3 7 and that we got our status code of 200 but the Python (41:53) interpreter that it's using is the default interpreter for my system so this is the global version of Python and I do have requests installed in that global version of Python but if I didn't have requests installed then that would fail even though I do have requests installed in my virtual environment so we want to set this up to use our virtual environment instead of our global Python to ange here now you don't have to make these changes but this is my preferred settings so I can do a code runner and again I can hit control space to make this autocomplete for me and I want to change this clear previous output I want to change that to true because I don't like a lot of previous (44:23) runs of my script taking up all of my screen okay and now the last thing that I'm going to change here is code runner show execution message that is true by default I want to set this equal to fals was that people would always ask me how to do input within sublime and it was actually hard to do within sublime and I would always just recommend against it I would just recommend instead using the terminal so to write your script within sublime and then use the terminal now within vs code if we want to use input then it's kind of the same process but now we have a terminal built in so I'm going to just get rid of my code here everything except the imports and now (46:44) I'm just going to use t I want to track so I'm just going to click on my project the one (48:31) that I've been working in so once we do that it's going to now put in all of the files here that are untracked now it looks like we have a lot it says there are over 3,000 but most of these are from our virtual environment and we usually don't want to even track our virtual environment so to ignore our that directory we just need to create a dot git ignore file and add that to what we're tracking with git within my folder e we could hover over them and just click on the plus icon beside each file so if I do that with git ignore we can see that that got staged or if we wanted to stage all of the changes then we can just click the extra options up here at the top right (50:45) and then if I scroll down here I can go to stage all changes so if I do that then we can see that now our script pi is staged as well so now to commit we can just click on this check mark here to commit and now it's going to ask us for a comm the integrated terminal so I'm gonna save that and now let me close down the terminal that we had before and now open that back up and now we should be using git bash instead and we can see that it still activates that virtual environment now my text is a little large here so I'm running on to a new line but it's large enough just so you all can see but normally this would all be on one line here so let me clear (53:08) this out just by running clear there and now I can run those get configurati nd now this is our new code over here on the right so the red is saying hey you removed all of this stuff here that's what was last committed it's now gone and the green over here is saying oh and this is what was added this we didn't have this here before and now we do so if that diff looks good then you can simply stage your changes you want to close down the diff here so we staged the changes here it says that it's modified now I can commit that and as a (55:25) commit message here I'll just source control tab I can simply click here with the extra options and I'm going to select this command here (57:20) push - and when I click push - it says well where do we want to push this we have this thing called origin here at this URL and that is what got added when we ran that command that get gave us or that github gave us so if I run that then it's going to push that up to github now it's asking me to log in here so let me log in really quick with my username and password it's been a wh the debug tab over here in our activity bar and now let me make this a little bit larger here we can see that it says we don't currently have any configurations but if I click the little gear icon here then we can see some different configurations so we (59:35) have Python file we have module Django flask so you can set up these configurations to where it'll run you know your main flask app from there and you can also specify ports and stuff like that for this video we're just going to look at ore interactive then we can also use let me make this a little smaller over here we can also use the debug console and use this to inspect anything we'd like so I'm gonna click on our additional views here click on debug console and within the debug console we can just use this like an interactive Python prompt so if I wanted to see the value of r dot okay then i could just run that and we can see that it gives us this feedback of exactly what these values are equal to at this (1:01:57) point in ing support that they have built in to vs code and I'm really loving their attention to detail and how they covered so many different aspects (1:03:37) of helping us manage our code as easily as possible so having the built-in support for all this stuff is definitely a nice addition that you're not gonna find in most other editors so to show some unit testing I'm going to close down my current project and I'm going to open up a different project that has some sample unit tests so I'm going to cl to say to install that for our default Python as well so that we stop seeing those pop-ups okay so now let me open up both of these unit tests here okay so now that we have some unit tests available here let's run open up our command palette and now let's type in discover tests and when we run discover tests then it's (1:06:11) going to come up with this pop-up here that says enable and configure test framework so I'm going to click on that and now it's going to ask us what unit testing framewor now we can see it says three tests pass one test failed so if I click on this status down here in the bottom then it'll ask us what we want to do so we can run all of the tests again we can simply just run the failed test which is a nice feature as well or we can view the test output if I look at the test output here then we can see it ran for test one of them failed and it failed because of an assertion error that 15 is not equal to 10 and that it failed on line 8 so it shows us exactly where o show you in this video and it's only going to take one second so I have some other preferred settings that I haven't shown in this video and (1:10:04) most of them are settings for changing how they editor looks in full-screen send mode and will allow me to run code without too much other stuff getting in the way and I want to show you these settings so that you can see exactly how I'm gonna have my vs code set up if you see me using this editor in future videos because I get a lot of question open up Zen mode here and we can see how I have this set up it's you know takes away our activity bar the blue bar down here at the bottom so it's just a lot more clean and the nothing is distracting us from the code itself and we can still run code by just clicking up here and clicking run code now it's telling me it (1:12:14) can't find the specified path and the reason is because like I was saying these are my Mac settings so the path that I have set up for my Mac is this is more of a Linux cally how to do anything within vs code that we'd want to do so we have all of the multi cursor selection here file management search and replace things like that so that is a nice reference there if you would like to learn any of those keyboard shortcuts okay so I think that is going to do it for this video I hope you all found this video helpful especially if you're trying to switch over to vs code for your Python development so personally I think they really knocked it "
2025年2月24日 星期一
訂閱:
張貼留言 (Atom)
精選文章
手機使用VPN進入NAS、DaikinAPP時,仍能使用其他APP如銀行,連上WIFI 或行動網路
為了避免手機使用VPN進入NAS、DaikinAPP時,仍能使用其他APP如銀行,連上WIFI 或行動網路,要修改Router Policy設定?需要把家中屬於VPN的網段設備與其他區隔?要如何設定? 為了達成您的需求: ✅ 手機連上 VPN(例如連回家中 TP-Link ER...
-
📌 第一次使用 VS Code 的完整指南 📍 適用對象: Windows 使用者, 第一次使用 VS Code ,希望 詳細步驟 避免出錯。 這份指南會 一步步 帶你從 安裝、設定、基本操作 到 執行程式 ,確保你能順利使用 VS Code!🚀 🔹 1....
-
在 Blogger 上取得更出色的搜尋結果 現在,利用搜尋運算子,你可以更有效地篩選 Blogger 上的「文章」和「網頁」檢視頁面。你可以同時使用這些搜尋字詞來進一步篩選結果。 使用搜尋運算子 前往 Blogger 的「文章」或「網頁」頁面。 ...
-
Max Planck量子科學家 請問何謂量子神學家?定義?量子與神學有何關係?主張內容?神學思想?著名的學者?其著作? 「量子神學家」不是一個正式的神學學派或明確的學術領域,而是一種試圖將 量子物理學 的概念與 神學 聯繫起來的跨學科研究方向。以下是相關概念的分析與背景: 1. ...
沒有留言:
張貼留言