How To Install Python on Windows 10 and 11
First created by Guido van Rossum in 1991, Python is a versatile programming language used by Raspberry Pi makers, data center sysadmins, and even industrial light and magic to bring movies to life. is.
Python is a great language to learn, and thanks to the Raspberry Pi over the past decade, there have been countless tutorials covering the full spectrum of programming projects.
Whether you’re a Python veteran, a “pythonista”, or a total novice, installing Python on Windows is easy. This how-to will walk you through installing Python 3 on Windows, show you two editors for beginners and intermediate and advanced users, and how to code in this amazing language.
Installing Python 3 on Windows 10 and 11
The installation process for Python 3 on Windows is easy, just follow a few extra steps. These instructions allow you to access Python from anywhere on your system and install software using the built-in package manager. Installing Python in this way allows you to create projects that work with your operating system, such as notifications and automated system tasks.
1. Open your browser Python website Download the Windows installer.
2. Double-click the downloaded file to install Python for all users. When Make sure Python is added to your path.[今すぐインストール]Click to get started. Adding Python to your path allows you to use the Python interpreter from any part of your filesystem.
3. After the installation is complete,[パスの長さ制限を無効にする]then click[閉じる]Click. Disabling the path length limit means that file paths can have more than 260 characters.
Four.[閉じる]Click to finish the installation.
Running Python on Windows
1. Open a command prompt, type “python” and press Enter.
2. Write a short Python script that uses a for loop to print a message to the Python shell 10 times.Press space four times to indent Otherwise you will get an error in Python. Press Enter to run the code.
for i in range(10):
print(“Python in the command prompt”)
Python comes with its own package manager, pip, which is used to install, update, and remove modules of pre-built Python code. These modules provide additional functionality.For demonstration purposes, install using pip joke A collection of modules, programmer jokes.
1. Open Command Prompt When Install pyjokes using pip and press Enter.
pip install pyjokes
2. Open the Python interpreter.
3. Import the pyjokes module and output jokes from the module. In our case we got “hip hip hooray” with an array containing two hips.
import pyjokes
print(pyjokes.get_joke())
4. Other modules are PyPi package index.
Getting started with Python on Mu
If you’ve never written a single line of Python code before, Mu is for you. Created by Nicholas Tollervey, Mu is designed with the beginner in mind. A simple interface means you can focus on your code. But don’t underestimate Mu. Under the hood there are tools for validating your code and working with a variety of boards such as the Raspberry Pi Pico, Adafruit CircuitPython, and many MicroPython boards, including Lego.
1. Open your browser mu website When Download the Windows installer.
2. Navigate to your Downloads folder When Double-click the Mu file to start the installation.
3. Agree to the license agreement and[インストール]Click. It will take some time for the installation process to complete.
4. Click Launch Mu Editor. When [完了]Click. This will exit the installer and launch Mu.
5. Wait for Mu to start. The first boot of Mu may take a while to complete, but subsequent boots are much faster.
Mu editor interface
Mu was designed with beginners in mind, and this is reflected in its user interface. There is no clutter and it is easy to understand.
The user interface is divided into three areas.
- menu bar. Each button’s function is identified by a large icon and descriptive text. Can create, save and load files. You can also run and stop code. You can test your ideas using the Python shell (REPL, Read, Eval, Print, Loop). Plotters can be used to visualize data via graphs. You can zoom in and out on your code, which is useful when presenting to large groups. The built-in checker and tidy application checks and formats your code using Python style guidelines.
- coding area. This is where you write the code for your project.
- Python shell. You can print the result of your code and use it to access the REPL.
Mu makes it easy to write Python code. By default, you write Python 3 code and run it on your machine. This is where Mu’s ease of use works against it, as there is no way to install Python modules. A module is a library of code that can be used to add new functionality. For example, RPi.GPIO and GPIO Zero are modules that allow Python to communicate with the Raspberry Pi GPIO.
If you’re getting started with Python, Mu is a great choice for introducing the language.
mu mode
Mu has one feature that makes it better than other novice editors. Mu has a “mode” button that can be used to create Python, MicroPython and CircuitPython.
2. Select a mode from the list. Mu comes with a large number of modes. You can write Python 3, create games with PyGame Zero, and build websites and apps with Flask. Create his MicroPython for Raspberry Pi Pico, micro:bit. ESP, pie board, Lego Spike. Alternatively, you can use his CircuitPython from Adafruit to create a physics computing project.
Plugging in a Raspberry Pi Pico, MicroPython, or CircuitPython board triggers Mu to ask if you want to change modes to suit your board. To demonstrate this, we will create a short project that blinks the Pcio’s onboard LED.
A Raspberry Pi Pico is required to follow this part of the how-to.
1. With Mu open, connect your Raspberry Pi Pico to your computer.
2. Use popup to change mode Raspberry Pi Pico (RP2040).
3. Mu editor is now in RP2040 mode. Click REPL to open a MicroPython shell (REPL) in Pico.
4. In the editorImport two modules. The first is to enable access to the GPIO and the second is to add a pause to the code.
import machine
from time import sleep
5. Create a led object When Used to set the onboard LED as an output. For the Raspberry Pi Pico W, use the “LED” line of code, and for the original Pico use the 25 line of code. The Pico has an LED connected to GPIO 25, the Pico W does not.
Raspberry Pi Pico W
led = machine.Pin('LED', machine.Pin.OUT)
raspberry pi pico
led = machine.Pin(25, machine.Pin.OUT)
6. Create a for loop that repeats 10 timesevery time the loop runs, it turns the LED on and off, prints a message to the REPL, and sleeps for 0.1 seconds.
for i in range(10):
led.toggle()
print("BLINK")
sleep(0.1)
7.[保存]Click and save the file to your computer as blink.py.
8.[実行]Click to start coding in Pico. Pico’s LED will flash and a “BLINK” message will appear on the REPL.
You know yourself well and need a lightweight editor to complete your Python code. Sure, you can install Visual Studio Code, PyCharm, etc. But if you just need to edit a few project files, Notepad++ is the way to go. Notepad++ is the swiss army knife of editors and works very well with Python. We will install Notepad++ and configure it to run Python code at the touch of a button.
Please note that you need to install the Python 3 interpreter. Instructions for doing so are at the beginning of this how-to.
1. Open your browser Notepad++ website Download the latest Windows Installer.
2. In the Downloads folder, double-click the file to launch the installer.
3. Set your preferred language and press[OK]Click.
Four.[次へ]Choose.
5. Select I Agree.
6.[次へ]Click.
7.[次へ]Click.
8.[インストール]Click to start the process.
9. [Run Notepad++]check the[Finish]Click to finish the installation and open Notepad++.
Notepad++ interface
Notepad++ has a more complex user interface than Mu, which reflects the editor’s flexibility. Notepad++ is not just a Python editor, it can be used to write PHP, Perl, JSON, etc.
- menu. Here you can load and save projects, create macros, and install plugins for specific languages.
- Editor. The code for your project is created here.
- workspace. If you’re working on a large project with multiple project files, you can load folders as workspaces for quick access to files.
Run Python code in Notepad++
1. Create a simple Python project that uses a for loop to print messages to the Python shell.
for i in range(10):
print("Writing Python in Notepad++")
2. Save the code as for_loop.py.
3.[実行]>>[実行]Click.
Four.[…]Click to navigate to the Python executable. Selecting a file adds the path to the dialog box. Add -i “$(FULL_CURRENT_PATH)” to the end of the path to force Notepad++ to open the file.[保存]Click.
Example path to Python
C:\Users\LattePanda\AppData\Local\Programs\Python\Python310\python.exe -i "$(FULL_CURRENT_PATH)"
5. Create a shortcut named Python3.10 to start the Python interpreter,[OK]Click. I chose ALT+SHIFT+P because it doesn’t conflict with other shortcuts on my system.
6. Run your Python code using shortcuts.