Building a Python programming environment: How to install Python in Windows

Installing Python on Windows is as simple as installing common software, just click "Next" after downloading the installation package.

Python installation package download address: https://www.python.org/downloads/

Open the link, you can see that there are two versions of Python, Python 3.x and Python 2.x, as shown in the following figure:


Figure 1 Screenshot of the Python download page (including Python 2.x and Python 3.x versions)

Python 3.x is a major upgrade. In order to avoid the introduction of historical burden, Python 3.x does not consider the compatibility with Python 2.x. As a result, many existing projects cannot upgrade Python 3.x smoothly, so they can only continue to use Python 2.x, and most of the new projects that have just started use Python 3.x, so the official still needs to maintain these two versions of Python.

I recommend beginners to use Python 3.x directly. As of now (2020-01-02), the latest version of Python is 3.8.x. We will use this version as an example to demonstrate the installation process of Python under Windows.

Click the version number or the "Download" button in the above picture to enter the download page of the corresponding version, and scroll to the end to see the Python installation packages for each platform.


Figure 2 Python installation packages for each platform


Explanation of prefixes:

  • Windows x86-64The 64-bit Python installer starts with ;
  • Windows x86The 32-bit Python installer starts with .


Description of suffixes:

  • embeddable zip fileThe green free installation version of the presentation .zipformat can be directly embedded (integrated) into other applications;
  • executable installerIndicates .exethe format of the executable program, which is a complete offline installation package, generally select this;
  • web-based installerIndicates that it was installed through the network, that is to say, what is downloaded is an empty shell, and the real Python installation package needs to be downloaded online during the installation process.


Here I choose "Windows x86-64 executable installer", which is a 64-bit complete offline installation package.

Double-click the downloaded python-3.8.1-amd64.exe to start installing Python officially, as shown in Figure 3.
 


Figure 3 Python installation wizard


Please check it as much as possible Add Python 3.8 to PATH, so that the directory where the Python command tool is located can be added to the system Path environment variable, which will be very convenient for developing programs or running Python commands in the future.

Python supports two installation methods, default installation and custom installation:

  • The default installation will check all components and install them on the C drive;
  • Custom installation can manually select the components to be installed and install them to other drive letters.


Here we choose custom installation and install Python to a common directory to avoid too many files on the C drive. Click "Customize installation" to enter the next step and select the Python components to be installed.
 


Figure 4 Select the Python components to install


If there is no special requirement, just keep the default, that is, check all.

Click "Next" to continue and select the installation directory.
 


Figure 5 Select the installation directory


Select your usual installation directory, click "Install", and wait for a few minutes to complete the installation.

After the installation is complete, open the Windows command line program (command prompt), enter the command in the window python(note that the letters pare lowercase), if the version information of Python appears and the command prompt appears >>>, it means that the installation is successful, as follows As shown in the figure.
 


Figure 6 Running the python command


Running the python command starts the python interactive programming environment. We can >>>enter the code later and see the execution result immediately. Please see the following example.
 


Figure 7 Writing code in the Python interactive environment


Press Ctrl+Zthe shortcut key or enter the exit() command to exit the interactive programming environment and return to the Windows command line program.

 

Supongo que te gusta

Origin blog.csdn.net/qq_34274756/article/details/130966224
Recomendado
Clasificación