Python leaning 3 : How to Intall Python
Because Python is cross-platform, it runs on Windows, Mac, and various Linux/Unix systems. Writing Python programs on Windows and putting them on Linux is also capable of running.
To start learning Python programming, you first have to install Python on your computer. Once installed, you’ll get the Python interpreter (that’s what’s responsible for running Python programs), a command line interactive environment, and a simple integrated development environment.
Installing Python 3
Currently, there are two versions of Python, a 2.x version and a 3.x version, which are incompatible. Since version 3.x is becoming more and more popular, our tutorial will be based on the latest Python 3.x version. Please make sure that the version of Python installed on your computer is the latest 3.x so that you can learn this tutorial painlessly.
Installing Python on Windows
First, download the corresponding installer for Python 3 from the official Python website depending on your version of Windows (64-bit or 32-bit) and then, run the downloaded exe installer:
install-py3
In particular, check the box Add Python 3.x to PATH, and then click “Install Now” to complete the installation.
Translated with DeepL.com (free version)
Installing Python on a Mac
If you are using a Mac, then the version of Python that comes with the system is 2.7.To install the latest Python 3, there are two ways:
Method 1: Download the Python 3 macOS version installer from the Python website, download it, double-click it to run and install it;
Method 2: If Homebrew is installed, install it directly via the command brew install python3.
Installing Python on Linux
If you are using Linux, then I can assume that you have Linux system administration experience and should have no problem installing Python 3 on your own, otherwise, switch back to Windows.
For the large number of students who are still using Windows, if you don’t plan on switching to a Mac in the short term, you can continue reading below.
Running Python
After a successful installation, open a command prompt window and type in python and two scenarios will occur:
Scenario one:
Translated with DeepL.com (free version)
┌────────────────────────────────────────────────────────┐
│Command Prompt - □ x │
├────────────────────────────────────────────────────────┤
│Microsoft Windows [Version 10.0.0] │
│(c) 2015 Microsoft Corporation. All rights reserved. │
│ │
│C:\> python │
│Python 3.12 ... │
│[MSC v... 64 bit (AMD64)] on win32 │
│Type "help", "copyright", "credits" or "license"... │
│>>> _ │
│ │
└────────────────────────────────────────────────────────┘
Seeing output like Python 3.xxx means that Python installation was successful!
The fact that you see the prompt >>> means that we are in the Python interactive environment, and you can type any Python code, and you will get the result of the execution immediately after you enter. Now, type exit() and enter to exit the Python interactive environment (just closing the command line window will also work).
Scenario 2: Getting an error:
┌────────────────────────────────────────────────────────┐
│Command Prompt - □ x │
├────────────────────────────────────────────────────────┤
│Microsoft Windows [Version 10.0.0] │
│(c) 2015 Microsoft Corporation. All rights reserved. │
│ │
│C:\> python │
│'python' is not recognized as an internal or external co│
│mmand, operable program or batch file. │
│ │
│C:\> _ │
│ │
└────────────────────────────────────────────────────────┘
This is because Windows looks for python.exe based on the path set by a Path environment variable, and reports an error if it doesn't find it. If you missed the Add Python 3.x to PATH checkbox during installation, you will have to manually add the path where python.exe is located to the Path.
If you don't know how to change the environment variables, we recommend running the Python installer again, making sure to remember to check Add Python 3.x to PATH.
Summary
Learn how to install Python into your computer and become proficient at opening and exiting the Python interactive environment;
When running Python on Windows, start the command line and then run python;
When running Python on Mac and Linux, open a terminal and then run python3.