Installing Python and Pygame in Visual Studio 2022

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello today i'm going to show you how to install python and pygame into your visual studio community 2022 edition it works almost exactly the same way for 2019 so there shouldn't be any differences first and foremost you need to open up your visual studio installer i'm assuming that you've already installed visual studio community 2022 and we just need to modify it if you haven't already installed it you can proceed with these same steps during your initial installation so it'll work exactly the same way so the first thing we want to do is modify the version of visual studio that we plan to use in this case i have two different versions i'm going to go ahead and use 2022 click on the modify button and then here you want to find the box marked python development editing debugging interactive development and source control for python so select that and it will select a set of things over here on the right hand side to install live share is really nice because that will allow you to work with another developer live in your own code base i'm gonna go install python 364 bit in addition to my normal python install click on modify and then you'll have to approve the installation and then this is going to take a couple of minutes so we'll wait for that to finish through the magic of video editing we are able to skip over that time it really only took about 30 seconds or so for that to install if i'd selected a few more options it still should only have taken about three minutes or so total now that that's installed we can go over to visual studio so go ahead and open your visual studio 2020 too and we're going to create a new project for python so if this is the window that comes up first then go ahead and use create new project if not in your other visual studio window you can go up to i think file new project or something like that so create that new project select python as your language if it is not already selected often if it's brand new visual studio will assume you want to begin working in it then click on the python application a project for creating a command line application that's just going to be basically an empty project it doesn't have a whole lot of other stuff which is going to help us make sure that our code compiles and runs quickly go ahead and click next put it wherever you want give it some name and then click create it'll take a couple of seconds and then it's going to pop up with a new python application notice that your python window will be empty nothing exciting going over over here in your code what's important here is going to be what's on the right in the solution explorer so first thing under python environments make sure that it has something listed there in this case the environment that is being used to build your project and run your project is in bold so in this case here it's python 3.10 64-bit and then the global default just means that that is the microsoft global default um on this particular machine you can have multiple versions of python running i'm not going to show you how to install a bunch of different ones now the next step we need to do is install pygame right so in this particular case i actually already have pygame installed because i already did that but i'm going to go ahead and remove it just so that i can go through the process all right so now you'll get an environment that looks something like this the only modules installed are pip and setup tools probably you may have some other things installed here if you've installed python in some other way on this machine before you might have a bunch of other modules don't worry about them just look to see if you have pi game or not if you don't then i'm going to show you now how to fix that so first thing is you want to right click on the name of the python environment that you want to use or you are using the one that's bolded click on manage python packages this is where it gets a little bit weird all right so first you can see i only have one environment installed on my app on my uh on my computer and that is the python 310 64-bit which is fine you may have other ones listed here that's fine just make sure that you have selected the one that you are using for this project then down here in this window where it says search pipel and installed packages this is actually an editable text window this is where you're going to search for the name of the module you want to install in this case game so just search for pie game it's going to come up with a bunch of different suggestions all right so the first one is almost always run command pip install pi game this is the one that you want to choose most of the time however there are some other options here if you want to install some of these other modules if you need any of them you can see here there's install pi game 2.1.2 that's kind of the default and that's what's going to happen when we run this command i almost always just click run command pip install pi game all right that's going to start the installation process and then over here in your output window you'll see information installing game collecting pie game it'll download the package then it'll say successfully installed blah blah blah and then right down here is what you're looking for that last line where it says successfully installed pi game if this is not successful look up in these other messages and look for errors or dependent packages that need to be installed first and then go and install those packages in the same way we just installed pygame so search for their name and then install them individually and then try installing pygame again generally python will install dependent packages but not always so but once you have that successfully installed pi game then you should be good to go so you can close the python manager and you can see now under our python 3.10 environment we now have pip pie game module and setup tools this is a visual confirmation that this module exists it's been installed and it is in this environment but let's just double check to make sure that it's actually running this is where it actually is relatively easy all you need to do go over to your dot py window and type in import pi game if this runs if this code runs successfully then pygame is installed and will be usable so go ahead and click start run this and it's going to pop up this window hopefully if everything goes well it'll say hello from the pi game community this is confirmation that pygame is correctly installed and is usable in this project so everything should be good to go and you should now be able to build your pie game games that's it good luck and enjoy creating games in pie game
Info
Channel: Dr. Dana
Views: 24,247
Rating: undefined out of 5
Keywords: game development, pygame, python, visual studio, install pygame, python tutorial, visual studio community 2022
Id: LbJl_KcHXOo
Channel Id: undefined
Length: 7min 29sec (449 seconds)
Published: Sun Sep 04 2022
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.