Why can't I download Pygame?
Getting started using Python on Windows for beginners
- 10 minutes to read
The following detailed instructions are aimed at beginners who want to familiarize themselves with Python under Windows 10.
Setting up the development environment
For beginners who are not yet familiar with Python, it is recommended to install Python via the Microsoft Store. When installing from the Microsoft Store, the basic Python3 interpreter is used, but in addition to providing automatic updates, your PATH settings are set up for the current user (so no administrator access is required). This is especially useful if you are in a training environment or in an organization that is restricting permissions or administrative access to your computer.
If you're using Python on Windows for Web development a different setup is recommended for your development environment. Instead of installing directly on Windows, we recommend installing and using Python via the Windows subsystem for Linux. For help, see: Getting started using Python for web development on Windows. If you'd like to automate common tasks in the operating system, check out our Getting Started Using Python on Windows for Scripting and Automation guide. For some advanced scenarios (such as when you need to access or modify installed Python files, make copies of binary files, or build Python DLLs directly), consider a specific Python release directly from python.org download or install an alternative, e.g. B. Anaconda, Jython, PyPy, WinPython, IronPython, etc. This is only recommended if you are an accomplished Python programmer and have specific reasons for choosing an alternative implementation.
To install Python using the Microsoft Store:
Go to the menu begin (lower left Windows icon), enter “Microsoft Store” and select the link to open the store.
Once the store is open, select in the top right menu Search and enter “python”. From the results under Apps, choose which version of Python you want to use. We recommend using the latest version, unless there is a reason not to do this (e.g. comparison with the version used in an existing project that you want to work on). After you have determined which version you want to install, choose Recall out.
After Python completes the download and installation process, open Windows PowerShell from the menu begin (lower left Windows symbol). With PowerShell open, enter to confirm that Python 3 has been installed on your computer.
The Microsoft Store installation of Python includes PIP, the default package manager. PIP allows you to install and manage additional packages that are not part of the standard Python library. Enter to confirm that you also have PIP available to install and manage packages.
Install Visual Studio Code
When using VS Code as a text editor / Integrated Development Environment (IDE), you can use IntelliSense (a code completion aid), Linting (helps avoid bugs in your code), Debug Assistance (helps you spot bugs in your code execution), code snippets (templates for small reusable code blocks) and unit tests (testing the code interface with different input types).
VS Code also includes a built-in terminal that lets you open a Python command line using the Windows Command Prompt, PowerShell, or any other tool of your choice. This establishes a seamless workflow between the code editor and the command line.
If you want to install VS Code, download the tool for Windows: https://code.visualstudio.com.
After VS Code is installed, you will also need to install the Python extension. To install the Python extension, you can select the VS Code Marketplace link or open VS Code and search for (CTRL + SHIFT + X) in the extension menu python search.
Python is an interpreted language, and in order to run Python code, you need to tell VS Code which interpreter to use. We recommend using the latest version of Python unless you have a specific reason to choose otherwise. After installing the Python extension, choose a Python 3 interpreter by using the Command palette Open (CTRL + SHIFT + P) and enter the command Python: Select Interpreter to search for and select the command. You can also choose the option Select Python Environment Use (Select Python Environment) on the lower status bar (a selected interpreter may already be displayed there). The command displays a list of available interpreters that VS Code can automatically find, including virtual environments. If you don't see the interpreter you want, see Configuring Python Environments.
To open the terminal in VS Code, select Show > terminal or alternatively use the keyboard shortcut CTRL + ` (with the grave accent). The standard terminal is PowerShell.
Open Python in your VS Code terminal by typing the command.
Try the Python interpreter by typing:. Python returns your "Hello World" statement.
Install Git (optional)
If you intend to collaborate on your Python code with others or to host the project in an open source location (like GitHub), VS Code supports version control with Git. The Source Control tab in VS Code will put all Changes tracked and common Git commands ("Add", "Commit", "Push", "Pull") integrated directly into the user interface. You must first install Git to enable the Source Control section.
Download Git for Windows from the git-scm website and install Git.
An installation wizard is included that asks you a series of questions about the settings for the Git installation. You should use all of the default settings unless you have a specific reason to change something.
If you've never used Git before, you can use GitHub guides to get started.
Hello World tutorial for some Python basics
According to the inventor Guido van Rossum, Python is a "high-level programming language with the readability of code as the central design philosophy and a syntax that enables programmers to express concepts in a few lines of code".
Python is an interpreted programming language. Unlike compiled languages, in which the code written must be translated into computer code in order for it to be executed by the computer's processor, Python code is passed directly to an interpreter and executed. You just enter your code and run it. Try it!
With the PowerShell command line open, type to run the Python 3 interpreter. (Some guides prefer to use the or command, which should work as well.) You know you've succeeded because the prompt displays “>>>” (three greater-than symbols).
There are several built-in methods you can use to make changes to strings in Python. Create a variable with. Press Enter to start a new line.
Print out your variable with. This will display the text “Hello World!”.
Find out the length of your string variable (the number of characters used) with. This indicates that 12 characters are used. (Note that the space is included in the total length.)
Convert the string variable to uppercase:. Now convert the string variable to lower case:.
Count the number of times the letter “l” appears in the string variable:.
In the string variable, look for a specific character - the exclamation point:. This indicates that the exclamation point is 11th in the string.
Replace the exclamation mark with a question mark:.
To quit Python, you can type, or "CTRL + Z".
We hope you enjoyed some of Python's built-in methods for changing strings. Now try creating a Python executable and running it using VS Code.
Hello World tutorial on using Python with VS Code
The VS Code team made an excellent Getting Started with Python tutorial that you can take by creating a "hello world" program with Python, running the executable, configuring the debugger, and installing packages like matplotlib and numpy leads. With these packages you can create graphical representations in a virtual environment.
Open PowerShell and create an empty folder named "hello". Navigate to this folder and open it in VS Code:
After opening VS Code, the new folder will be Hello in the left ExplorerWindow is displayed. At the bottom of VS Code, open a command line window by pressing CTRL + ` Press (grave accent) or view > terminal choose. When you start VS Code in a folder, that folder automatically becomes your “workspace”. VS Code saves the specific settings for this workspace, which do not belong to the globally saved user settings, in the file ".vscode / settings.json".
Continue with the tutorial in the VS Code documentation: Create a Python Hello World source code file.
Create a simple game with pygame
Pygame is a popular Python game development package that is designed to teach students how to code in a fun way. Pygame displays graphics in a new window. Because of this, it does not work when using the WSL method on the command line. However, if you installed Python through the Microsoft Store as described in this tutorial, it will work fine.
After installing Python, install pygame from the command line (or the terminal in VS Code) by typing.
Test the installation by running a sample game:.
If everything works, the game will open a window. Close the window when you've played enough.
Here's how to start creating your own game
Open PowerShell (or Windows Command Prompt) and create an empty folder named "bounce". Navigate to this folder and create a file in it called “bounce.py”. Open the folder in VS Code:
Using VS Code, type (or copy and paste) the following Python code:
Save the file as:.
Run the file on the PowerShell terminal by typing:.
Try adjusting some of the numbers to see what effect they have on the bouncing ball.
For more information on creating games with pygame, visit pygame.org.
Resources for further learning
We recommend the following resources to learn more about Python development on Windows.
Online courses to learn Python
Introducing Python on Microsoft Learn: Try the Microsoft Learn interactive platform and gain experience points for completing this module with the basics of writing simple Python code, declaring variables, and working with console input and output. The interactive sandbox environment is an ideal starting point for users who have not yet set up a Python development environment.
Python at Pluralsight: 8 courses, 29 hours: The Python Learning Path at Pluralsight offers online courses that cover a variety of topics related to Python, including a tool to measure your skills and find gaps.
Tutorials on LearnPython.org: Get started with Python without installing or setting up anything with these free interactive Python tutorials from the folks at DataCamp.
Tutorials on python.org: Here you will find an introduction to the basic concepts and features of the programming language and the Python system.
Learning Python on Lynda.com: A Basic Introduction to Python.
Working with Python in VS Code
Editing Python in VS Code: Learn more about how to take advantage of VS Code's AutoComplete and IntelliSense support for Python, including customizing the behavior - or how to just turn these features off.
Linting in Python: Linting is the process of running a program that analyzes your code for possible errors. Learn more about the different forms of linting support in VS Code for Python and how to set up linting.
Debugging Python: Debugging is the process of detecting and removing errors from a computer program. This article describes how to initialize and configure debugging for Python using VS Code, how to set and check breakpoints, attach a local script, debug different types of apps or on a remote computer, and do some basic bug fixes.
Unit tests in Python: Use a walkthrough to learn some background about unit tests, how to enable a test framework, how to create and run tests, and how to debug tests, and test configuration settings.
Is this page helpful?
- How do you send a fish
- What are the best Tamil story books
- What is the name of the fear of blood
- What motivates high frequency engineers
- Hi is an acceptable email opening line
- What hobby can you talk about for hours
- Ocelot cats attack humans
- Will Apple develop a car
- What is the scope of the clinical pharmacist
- How do I download a PSP game
- Why is SEO so important for companies
- What is normal and what is not
- When was the 10-speed bicycle invented?
- Why do I lie so often
- Why do Filipinos tend to have good handwriting
- Did someone lie right on your face
- Same as standard chartered credit card
- Why is antifreeze poisonous to cats
- How true is Alex Jones
- Which novel by Chetan Bhagats makes no sense
- What is LeBron James daily routine
- What is Computer Aided Origami
- Will an amaryllis bloom more than once
- Do you like free giveaways