Table of Contents
##3.1 Supplement" >##3.1 Supplement
4. Other methods" >4. Other methods
4.1 Python official Pypi menu" >4.1 Python official Pypi menu
Home Backend Development Python Tutorial Summary of common methods for installing third-party libraries in Python

Summary of common methods for installing third-party libraries in Python

Nov 24, 2022 pm 05:40 PM
python

This article brings you relevant knowledge about Python, which mainly introduces the common methods of installing third-party libraries. Let’s take a look at them together. I hope it will be helpful to everyone.

Summary of common methods for installing third-party libraries in Python

[Related recommendations: Python3 video tutorial ]

In the study of pyhton, I believe everyone will usually encounter third-party libraries The installation problem is a headache for many beginners. Here I will make some simple summaries on how to install third-party libraries correctly and efficiently without taking detours

Installation method

1 . Install through pychram

This is the simplest and most direct method in my opinion, but it is also the easiest to report errors.

Open File-Settings-Project-Python Interpreter

Summary of common methods for installing third-party libraries in Python
From here you can see the third-party libraries and versions you have installed, and then click the plus sign below to proceed Add to. Here I take numpy as an example. Search for the library you want at the top, and then select the version you want at the bottom right. If not checked, it will default to the latest version. Click Install Packages to install it.

Summary of common methods for installing third-party libraries in Python

2. pip installation method

If the installation in pycharm fails, or pycharm is not used, you can directly Install using pip method.
First open cmd and directly enter pip install the third-party library you want to install (here I still use numpy as an example)
Summary of common methods for installing third-party libraries in Python
Here, I will also add some information about Some methods of updating and uninstalling pip:
(1) Upgrading pip itself

1

py -m pip install --upgrade pip

Copy after login

(2) pip installation/uninstallation/upgrade

1

pip install 包名              #安装pip uninstall 包名            #卸载pip install --upgrade 包名    #升级

Copy after login

(3) pip viewing installed Package

1

pip list

Copy after login

(4) pip checks which packages need to be updated:

1

pip list --outdated

Copy after login

(5) pip checks the details of a package:

1

pip show 包名

Copy after login

(6) pip installation specification Version of the package:

1

2

3

4

5

6

pip install 包名==版本号

例如:

pip install numpy==1.20.3pip install 'matplotlib>3.4'pip install 'matplotlib>3.4.0,=, , <h2>

<a id="3_whl_55"></a>3. Download the whl file to local offline installation</h2><p>If the first two methods fail, then my most recommended method is the third Although it is not as convenient as the first two, it is effective in personal testing and will not report errors! Enter the website <a href="https://www.php.cn/link/7d7c61cdf50443a0079ebb5011209dbf">https://www.php.cn/link/7d7c61cdf50443a0079ebb5011209dbf</a> and find the library you need to download. Here I take matplotlib as an example: <br> First of all, you must pay attention to <mark> before installing this Some libraries that it depends on before the package must be installed first before installing the one you want, otherwise an error </mark> will be reported. <br> At the same time, after updating a certain library, you must also pay attention to updating the libraries it depends on at the same time, otherwise errors will occur. <br><img src="/static/imghw/default1.png" data-src="https://img.php.cn/upload/article/000/000/067/36cabce7a764653c64263a29550b7634-3.png" class="lazy" alt="Summary of common methods for installing third-party libraries in Python"><br> Then select and download based on your python version and number of bits. Here, because my python version is 3.7.9 and the number of bits is 64 bits, I chose matplotlib‑3.5.1 ‑cp37‑cp37m‑win_amd64.whl. <br> Save the downloaded whl file to the folder <code>Python37\Lib\site-packages</code>, open cmd under the file, enter <code>pip install whl file name</code> to install. <br><img src="/static/imghw/default1.png" data-src="https://img.php.cn/upload/article/000/000/067/c522c75f56fd335401a3847b6e4f524c-4.png" class="lazy" alt="Summary of common methods for installing third-party libraries in Python"></p><p><img src="/static/imghw/default1.png" data-src="https://img.php.cn/upload/article/000/000/067/d5fdf37a9f18234fe0c302793ed1f48c-5.png" class="lazy" alt="Summary of common methods for installing third-party libraries in Python"></p><h3 id="a-id-Supplement-a"><a id="31__65">##3.1 Supplement</a></h3>During my installation process, most of the failed problems were due to no It is caused by installing the corresponding dependent package, so after reporting an error, be sure to check whether the corresponding package is installed and update it at the same time. <p> For example, I once encountered this problem: <br>AttributeError: module 'matplotlib' has no attribute 'get_data_path'<code>, which troubled me for an afternoon and did not solve it. Finally, I found that a package that matplotlib depends on did not Installed. </code><br><img src="/static/imghw/default1.png" data-src="https://img.php.cn/upload/article/000/000/067/d5fdf37a9f18234fe0c302793ed1f48c-6.png" class="lazy" alt="Summary of common methods for installing third-party libraries in Python"></p><h2 id="a-id-Other-methods-a"><a id="4_71">4. Other methods</a></h2><h3 id="a-id-PythonPypi-Python-official-Pypi-menu-a"><a id="41_PythonPypi_72">4.1 Python official Pypi menu</a></h3> Directly search for third parties Library to install, address: <p>https://www.php.cn/link/4b6cf59a2a5b31fc68aa6f9524067ef8<a href="https://www.php.cn/link/4b6cf59a2a5b31fc68aa6f9524067ef8"></a></p><h3>

<a id="42_pip_74"></a>4.2 Domestic mirror sources solve the problem of slow pip installation</h3><p>Under Windows systems, when installing third-party libraries, you often encounter timeouts or slow downloads. This is Because the Python server is abroad, sometimes the network speed is too slow when downloading with pip. In this case, it is recommended to use a domestic mirror source for installation. <br> Installation method: Open cmd and add the "-i" or "-index" parameter. Take numpy as an example: `pip install -i https://www.php.cn/link/a6455ffc4e47fd737db213366771ec0e numpy<br> Several commonly used domestic image sources: <br> Tsinghua: <a href="https://www.php.cn/link/a6455ffc4e47fd737db213366771ec0e">https://www.php .cn/link/a6455ffc4e47fd737db213366771ec0e</a><br> Alibaba Cloud: <a href="https://www.php.cn/link/4901e49e1e2d9c85659eef5b2ffbe12f">https://www.php.cn/link/4901e49e1e2d9c85659eef5b2ffbe12f</a><br> University of Science and Technology of China: <a href="https://www.php.cn/link/1cbbae823ca54abfb04302180fd84137">https://www. php.cn/link/1cbbae823ca54abfb04302180fd84137</a><br> Douban: <a href="https://www.php.cn/link/3c0093f155f7a0bf00afca91dc8fb9b8">https://www.php.cn/link/3c0093f155f7a0bf00afca91dc8fb9b8</a></p><h1>

<a id="_83"></a>Summary</h1> <p>For most novices, the installation of Python third-party libraries is definitely a stumbling block on their way to learning. I have also had a headache with this problem. But as far as my personal installation is concerned, I have personally tested the first three methods. The first and second methods are the simplest and most direct, but they are error-prone because you are not familiar with the dependencies between various packages, so I strongly recommend that if the first two installations are unsuccessful, you must try the third one! ! <mark>Check clearly the packages that need to be installed before installing the third-party libraries you need, otherwise the installation will not be successful</mark>! ! I don’t use the fourth method often, because I think the first three methods are enough to install the libraries you need. Of course, if you need it, you can learn more about the fourth method in detail, but I won’t cover it here. Too many introductions! </p><p>【Related recommendations: <a href="http://www.php.cn/course/list/31.html" target="_blank">Python3 video tutorial</a>】</p>

Copy after login

The above is the detailed content of Summary of common methods for installing third-party libraries in Python. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
WWE 2K25: How To Unlock Everything In MyRise
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Do mysql need to pay Do mysql need to pay Apr 08, 2025 pm 05:36 PM

MySQL has a free community version and a paid enterprise version. The community version can be used and modified for free, but the support is limited and is suitable for applications with low stability requirements and strong technical capabilities. The Enterprise Edition provides comprehensive commercial support for applications that require a stable, reliable, high-performance database and willing to pay for support. Factors considered when choosing a version include application criticality, budgeting, and technical skills. There is no perfect option, only the most suitable option, and you need to choose carefully according to the specific situation.

How to use mysql after installation How to use mysql after installation Apr 08, 2025 am 11:48 AM

The article introduces the operation of MySQL database. First, you need to install a MySQL client, such as MySQLWorkbench or command line client. 1. Use the mysql-uroot-p command to connect to the server and log in with the root account password; 2. Use CREATEDATABASE to create a database, and USE select a database; 3. Use CREATETABLE to create a table, define fields and data types; 4. Use INSERTINTO to insert data, query data, update data by UPDATE, and delete data by DELETE. Only by mastering these steps, learning to deal with common problems and optimizing database performance can you use MySQL efficiently.

Navicat's method to view MongoDB database password Navicat's method to view MongoDB database password Apr 08, 2025 pm 09:39 PM

It is impossible to view MongoDB password directly through Navicat because it is stored as hash values. How to retrieve lost passwords: 1. Reset passwords; 2. Check configuration files (may contain hash values); 3. Check codes (may hardcode passwords).

HadiDB: A lightweight, horizontally scalable database in Python HadiDB: A lightweight, horizontally scalable database in Python Apr 08, 2025 pm 06:12 PM

HadiDB: A lightweight, high-level scalable Python database HadiDB (hadidb) is a lightweight database written in Python, with a high level of scalability. Install HadiDB using pip installation: pipinstallhadidb User Management Create user: createuser() method to create a new user. The authentication() method authenticates the user's identity. fromhadidb.operationimportuseruser_obj=user("admin","admin")user_obj.

Does mysql need the internet Does mysql need the internet Apr 08, 2025 pm 02:18 PM

MySQL can run without network connections for basic data storage and management. However, network connection is required for interaction with other systems, remote access, or using advanced features such as replication and clustering. Additionally, security measures (such as firewalls), performance optimization (choose the right network connection), and data backup are critical to connecting to the Internet.

How to optimize MySQL performance for high-load applications? How to optimize MySQL performance for high-load applications? Apr 08, 2025 pm 06:03 PM

MySQL database performance optimization guide In resource-intensive applications, MySQL database plays a crucial role and is responsible for managing massive transactions. However, as the scale of application expands, database performance bottlenecks often become a constraint. This article will explore a series of effective MySQL performance optimization strategies to ensure that your application remains efficient and responsive under high loads. We will combine actual cases to explain in-depth key technologies such as indexing, query optimization, database design and caching. 1. Database architecture design and optimized database architecture is the cornerstone of MySQL performance optimization. Here are some core principles: Selecting the right data type and selecting the smallest data type that meets the needs can not only save storage space, but also improve data processing speed.

Can mysql workbench connect to mariadb Can mysql workbench connect to mariadb Apr 08, 2025 pm 02:33 PM

MySQL Workbench can connect to MariaDB, provided that the configuration is correct. First select "MariaDB" as the connector type. In the connection configuration, set HOST, PORT, USER, PASSWORD, and DATABASE correctly. When testing the connection, check that the MariaDB service is started, whether the username and password are correct, whether the port number is correct, whether the firewall allows connections, and whether the database exists. In advanced usage, use connection pooling technology to optimize performance. Common errors include insufficient permissions, network connection problems, etc. When debugging errors, carefully analyze error information and use debugging tools. Optimizing network configuration can improve performance

How to solve mysql cannot connect to local host How to solve mysql cannot connect to local host Apr 08, 2025 pm 02:24 PM

The MySQL connection may be due to the following reasons: MySQL service is not started, the firewall intercepts the connection, the port number is incorrect, the user name or password is incorrect, the listening address in my.cnf is improperly configured, etc. The troubleshooting steps include: 1. Check whether the MySQL service is running; 2. Adjust the firewall settings to allow MySQL to listen to port 3306; 3. Confirm that the port number is consistent with the actual port number; 4. Check whether the user name and password are correct; 5. Make sure the bind-address settings in my.cnf are correct.

See all articles