How to install third-party libraries in python, how to install pygame module in python

Hello everyone, this article will focus on how to install the matplotlib module in python. How to install the pygame module in python is something that many people want to understand. To understand how to install a third-party library in python, you need to understand the following things first.

Table of contents

1. python official website

2. In the Downloads section of the official website, select the corresponding operating system

3. Enter the page corresponding to windows and select the python version

(1) Select the stable release version of python Stable Releases

(2) Download the python installation program Windows Installer

4. Run Windows Installer to install python

(1) Select custom installation

(2) Optional Features Settings

(3)Advanced Options

(4)Installation

5. Python development environment tools

6. Application fields of python

The latest Python installation detailed tutorial in 2023

1. python official website

        Python's official website mainly includes python's About (introduction), Downloads (download), Documentation (documentation),

Community (group), Success Stories (success stories), News (news), Events (event dynamics) and other columns. The homepage address of the Python official website is shown in Table 1-1 below.

Table 1-1 Python official website address

Python official website address

Welcome to Python.org

2. In the Downloads section of the official website, select the corresponding operating system

       Open the Python official website address in Table 1-1 above, as shown in Figure 2-1 below. Place the mouse in the Downloads column of the web page and select the Windows operating system there.

Figure 2-1 python home page

3. Enter the page corresponding to windows and select the python version

(1) Select the stable release version of python Stable Releases

        Click to enter the page corresponding to the windows operating system to display the python installation version. These python installation versions are suitable for

windows operating system.

Figure 3-1 Python stable and pre-release versions

          Figure 3-1 shows the Stable Releases on the left and the Pre-releases on the right. The former is a relatively complete and stable version that has been tested, while the latter is still under testing and may not be perfect. Therefore, we download the version on the left. Stable Releases.

(2) Download the python installation program Windows Installer

Figure 3-2 Python’s embedded package Windows embeddable package

        The Windows embeddable package in the red box in Figure 3-2 is the Windows embeddable package of python. After decompression

Is a folder, which is a minimal python running environment, excluding doc, idle, pip, etc. This version is mainly used for embedding into other programs.

        In Figure 3-2, 32-bit refers to a 32-bit operating system. The downloaded package is suitable for 32-bit operating systems and is based on a 32-bit processor. ARM64 is the processor architecture in the AArch64 state. The downloaded package is suitable for ARM64 processors and is based on 64-bit processors.

        64-bit refers to a 64-bit operating system, based on a 64-bit processor. The downloaded package is suitable for 64-bit operating systems. Right-click My Computer and left-click Properties in the menu to view the hardware configuration of your computer. The type of your computer's operating system is shown in the red box in Figure 3-3 below.

Figure 3-3 Computer specifications

       Since the Windows embeddable package is a simplified version of python, it is mainly used to embed other applications.

We use python for program development and need to download the Windows Installer installation program. This installer has a relatively complete python development environment. The installation program of Python's Windows Installer is shown in the red box in Figure 3-4 below.

Figure 3-4 python installation program Windows Installer

         According to the number of bits of your computer's operating system, choose to download the python installation program Windows corresponding to the red box in Figure 3-4.

Installer, the 64-bit operating system is generally used now, download the Windows installer (64-bit) in the red box in Figure 3-4.

4. Run Windows Installer to install python

(1) Select custom installation

        The Windows operating system allows the creation of multiple account users. Each account has its own usage rights. Install Now defaults to

Current account installation, installation path and content are default.

Figure 4-1 python default installation

Use admin privileges when installing py.exe

       In the Windows system, the administrator account Administrator has the highest access rights and has the right to access other accounts, but personal accounts do not have mutual access rights.

       Check this option to install the python executable program with administrator privileges. Install python with administrator rights, other windows

You can use python after logging into the system with your account (User).

       If this item is not checked and the current account is a personal account, after installing Python, other non-administrator accounts cannot use the Python installed by this account when logging into the Windows system.

Add python.exe to PATH

       Check this item to add python to the system path of windows to facilitate automatic recognition by the operating system.

       Figure 4-1 The default installation of InstallNow will automatically install additional IDLE, pip, documentation, and Creates shortcuts

and file associations (create shortcuts in the start menu, create file associations). The default installation installs relatively basic content, but already has basic python development functions. If you want to reduce or increase functions, or specify the installation path, you can choose a customized installation.

       Usually we choose custom installation, which can add more functions. The Customize installation in the red box in Figure 4-2 is customized.

Installation, below we choose custom installation.

Figure 4-2 python custom installation

        Check Use admin privileges when installing py.exe and Add python.exe to PATH, click

Customize installation Enter custom installation and enter the python optional function setting interface shown in Figure 4-3.

(2) Optional Features Settings

Figure 4-3 python optional functions

Documentation

       Install the python offline documentation file, which is usually the python instruction manual. This option is optional.

pip

       Installing pip can install libraries external to Python in the cmd command window. Check this option. After installation, you can start it by win+r

In the run window, enter cmd, enter pip install library name in the cmd command window, and the library can be automatically downloaded and installed. Enter pip unstall library name to uninstall this library. Use pip in the default path of the cmd command window to install or uninstall the library. Generally, it is installed in the Lib→site-packages folder under the python path. Uninstallation also uninstalls the library in the Lib→site-packages folder under the python path.

tcl/tk and IDLE

       Install tkinter and IDLE development environment. Whether to check this option depends on your needs. The Tkinter module is an interface to Python's standard Tk GUI toolkit. The tkinter module can create GUI applications. IDLE is Python's integrated development and learning environment. Its full name is Integrated Development and Learning Environment. It is a visual shell command line and a simple command running window. After installation, an IDLE shortcut is generated in the computer start menu (lower left corner of the windows desktop). .

Python test suite

       Installs Python's standard library test suite, which can be used to execute written test cases,

Used to test whether the written classes and methods meet expectations. Whether this item is checked or not can be determined according to needs.

py launcher

       launcher is a python launcher for windows that helps us locate and execute different python versions,

Check this item.

for all users(requires admin privileges)

        The launcher is available to all Windows accounts. Administrator rights have been checked in the installation settings above. Whether this option is checked or not depends on your needs.

         All options in Figure 4-3 can be checked, click next to enter the python advanced option setting interface shown in Figure 4-4.

(3)Advanced Options

Figure 4-4 python advanced options

Install Python 3.11 for all users

       It is available for all Windows accounts. Whether this item is checked or not can be determined according to the needs.

Associate files with Python(requires the 'py'launcher)

       File association, associate files with .py suffix to Python (you need to install the python launcher launcher), check this option.

Create shortcuts for installed applications

       Create shortcuts for installing applications. The created shortcuts will be displayed in the start menu. Check this option.

Add Python to environment variables

       Add python as the system environment variable and check this option. After checking Add python.exeto PATH in the previous steps,

This item is checked automatically.

       An environment variable is an object with a specific name in the operating system, which contains one or more

Information used by the application. When asking the system to run a program without telling it the full path to where the program is located,

In addition to looking for this program in the current directory, the system will also go to the path specified in path to find executable variables.

Precompile standard library

        The Python program code file (.py) must first be compiled into bytecode and then executed in the virtual machine.

        Python's standard library is a built-in library that is installed by default when Python is installed (also called a built-in library). Precompile standard library (Precompile standard library) compiles the .py file of the standard library into a .pyc bytecode file during installation. You can save the need for compilation when running later, and it will be faster. This option can be checked.

Download debugging symbols

       Download debugging symbols. Debugging symbols can help debug the program and record the relationship between symbols such as variables and functions and memory location. Whether this option is checked can be determined according to needs.

Download debug binaries(requires VS 2017 or later)

       Download the debugging binary file (VS 2017 needs to be installed, VS is a powerful development tool launched by Microsoft),

Whether this item is checked or not can be determined according to needs.

Customizeinstall location

       Customize the installation path, you can specify the path to install python.

        In Figure 4-4, you can check according to your own needs. Here, check the first five items, specify the installation path, and then click Install to enter the python installation progress interface shown in Figure 4-5.

(4)Installation

Figure 4-5 Python installation progress

         Figure 4-5 After the installation progress is completed, the prompt interface for successful python installation shown in Figure 4-6 appears. At this point, python has been installed.

Finish.

Figure 4-6 python installation completed

        Figure 4-6 prompts that the python installation is complete. Click Close. The python installation is complete and the computer can use python.

5. Python development environment tools

        After we install python, there will be a python.exe file in the directory in the installation path. This file is a python interpreter. Its function is to convert python code into bytecode and interpret it for execution. If we want to program in python, we need to use development tools.

        There is an idle.pyw file in the...\Lib\idlelib folder under the python installation path. This file is the integrated development learning environment for the python program, that is, the integrated development environment tool that comes with python, usually referred to as IDLE (IntegratedDevelopment and Learning Environment) tools. Check IDLE in the above installation steps, and generate a shortcut to IDLE in the computer start menu (lower left corner of the windows desktop) after installation.

        We can use the IDLE tool for python development, but the IDLE tool is more suitable for running and debugging some simple small programs, not suitable for project development.

        In order to improve project development and management efficiency, we can use the PyCharm tool for python language development. PyCharm is a Python IDE (Integrated Development Environment, integrated development environment).

        PyCharm has a set of tools that can help us improve the efficiency of Python language development. PyCharm provides code editing, debugging, syntax highlighting, project management, code jumps, smart prompts, auto-complete and other functions to help us write python code more efficiently (that is, python project development).

        Therefore, we can install PyCharm for python development. For a detailed installation tutorial of PyCharm, see

Detailed tutorial on the latest PyCharm installation .

        In addition, we can also install the VS Code (Visual Studio Code) code editor tool for python development. For the detailed installation tutorial of VS Code, see

Detailed tutorial on the latest VS Code installation .

       Similar to this kind of development environment tools, there are SublimeText, Eclipse+PyDev, etc.

6. Application fields of python

       Foreign Google, Youtube, Dropbox, etc., domestic Baidu, Sina, Sohu, Tencent, Ali, Netease,

Taobao, Zhihu, Douban, etc., the main application areas of Python are as follows.

(1) Web application development

       As Python's web development framework gradually matures (such as Django, Flask, Tornado, Web2py, etc.), programmers can more easily develop and manage complex web programs.

(2) Automated operation and maintenance

       Automated operation and maintenance refers to a process-based framework that associates events with IT processes. Once the performance of the monitored system exceeds the standard or

Downtime will trigger relevant events and pre-defined processes, which can automatically initiate fault response and recovery mechanisms.

       Use some open source automation tools to manage servers, such as the industry-popular Ansible (based on Python), which can help operation and maintenance engineers solve repetitive tasks.

(3) Machine learning

        Can study artificial intelligence, language recognition, image recognition, natural language processing, etc.

(4) Calculation and data analysis

        Python has quite complete and excellent libraries for data analysis and visualization, such as NumPy, SciPy, Matplotlib,

pandas, etc., which can meet the needs of Python programmers to write scientific computing programs.

(5) Web crawler

       Python provides many tools for writing web crawlers, such as urllib, Selenium and BeautifulSoup, etc.

Scrapy, a web crawler framework, is also provided.

(6) Game development

        The more famous games SidMeier's Civilization (Civilization) and EVE (Star Wars Eve) were developed using Python.

(7) Cloud Computing

        The open source cloud computing solution OpenStack is developed based on Python.

The latest PyCharm installation detailed tutorial:

Latest PyCharm installation detailed tutorial_pycharm installation tutorial_thefg's blog-CSDN blog

Detailed installation tutorial for the latest VS Code (Visual Studio Code):

Latest VS Code installation detailed tutorial_vscode local installation_thefg's blog-CSDN blog

The latest PyCharm basic usage (1)------File settings and management operations:

The latest basic use of PyCharm (1)------File settings and management operations_pycharm page layout_thefg's blog-CSDN blog

Finally, you are welcome to like, collect and follow!

Guess you like

Origin blog.csdn.net/i_like_cpp/article/details/132142976
Recommended