Как установить pygame в visual studio code

от admin

How to import pygame in visual studio code?

I use visual studio code for coding (python) and now I have to write a program with pygame for my project and I can’t import pygame in visual studio code (I can import it with the python script, it just can’t be import ed in visual studio code).

4 Answers 4

Here is the solution I tried:

From left bottom of your vs code you can find python environment, you can in the image I marked red:

enter image description here

after clicking in the red marked area you can see below option to select:

enter image description here

from the option select your desired one. Suppose first i was try selecting 2nd one but it was not working then i tried with the last one and it worked.

How to Install Pygame in Visual Studio Code

Pygame is a library that helps us create games using Python. Pygame uses SDL (short for Simple DirectMedia Layer), which helps us get access to the keyboard, mouse, and graphics. Pygame runs on almost every platform.

This guide shows you how to import Pygame in Visual Studio Code.

Step 1: Download Python

Download and install Python from python.org/downloads with default configurations.

Download Python

Step 2: Install Pygame

To install Pygame through VS Code, follow these steps:

        From the top-level View menu, select Terminal. Alternatively, you can press Ctrl + ‘.

      Terminal

      Install Pygame

      Step 3: Create a new Pygame project

      After installing the Pygame library, we must import all functions from it. We use the “import” keyword to import a library.

      For this example, let us create a simple Pygame application that displays Hello World on the screen. Follow the steps below:

        Click on the Open Folder button from the “Explorer” tab. Then, open or create a folder from your preferred directory. In my case, I’m creating a folder named “Test” which will be saved on my Desktop.

      Open Folder

      New File

      Filename

      Pygame Code

      Run

      Voilà! We’ve successfully imported and created our first Pygame application in VS Code.

      How do I get pygame to work with visual studio code?

      I´ve been struggling with finding any good instruction, I need this for school so if anyone can help me please comment.

      What is stopping you from using it? I only ask because there is a ton if things that you might need to do to get it to run.

      20 questions debug style: does your program run outside of vs?

      The program should work within visual studio like the pacetches and when I send it to my teacher he has to be able to run it. I think he uses pycharm but so long as he has the import I think it's fine

      Pygame Snippets

      Python Extended is a vscode snippet that makes it easy to write codes in python by providing completion options along with all arguments.

      Preview

      Usage

      Run vscode and on a python file, type the method name to complete and press tab or enter on selection.

      How to install

      Open vscode. Press F1 , search " ext install " followed by extension name, in this case: " ext install Pygame Snippets " without the ">". Or if you prefer ">ext install", hit enter, search "Pygame Snippets".

      Contributions

      Feel free to contribute to the extension. Fork it on github

      License

      Read LICENSE on the github repository

      Acknowledgements

      I’d first like to say a very big thank you to God my creator. Without him, this wouldn’t be possible.

      Читать:
      Обновить до цветовых категорий outlook что это

Похожие статьи