search
HomeBackend DevelopmentPython TutorialSummary of common methods for installing third-party libraries in 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

py -m pip install --upgrade pip

(2) pip installation/uninstallation/upgrade

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

(3) pip viewing installed Package

pip list

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

pip list --outdated

(5) pip checks the details of a package:

pip show 包名

(6) pip installation specification Version of the package:

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/imghwm/default1.png" data-src="https://img.php.cn/upload/article/000/000/067/36cabce7a764653c64263a29550b7634-3.png?x-oss-process=image/resize,p_40" 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/imghwm/default1.png" data-src="https://img.php.cn/upload/article/000/000/067/c522c75f56fd335401a3847b6e4f524c-4.png?x-oss-process=image/resize,p_40" class="lazy" alt="Summary of common methods for installing third-party libraries in Python"></p><p><img src="/static/imghwm/default1.png" data-src="https://img.php.cn/upload/article/000/000/067/d5fdf37a9f18234fe0c302793ed1f48c-5.png?x-oss-process=image/resize,p_40" 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/imghwm/default1.png" data-src="https://img.php.cn/upload/article/000/000/067/d5fdf37a9f18234fe0c302793ed1f48c-6.png?x-oss-process=image/resize,p_40" 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>

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
This article is reproduced at:CSDN. If there is any infringement, please contact admin@php.cn delete
详细讲解Python之Seaborn(数据可视化)详细讲解Python之Seaborn(数据可视化)Apr 21, 2022 pm 06:08 PM

本篇文章给大家带来了关于Python的相关知识,其中主要介绍了关于Seaborn的相关问题,包括了数据可视化处理的散点图、折线图、条形图等等内容,下面一起来看一下,希望对大家有帮助。

详细了解Python进程池与进程锁详细了解Python进程池与进程锁May 10, 2022 pm 06:11 PM

本篇文章给大家带来了关于Python的相关知识,其中主要介绍了关于进程池与进程锁的相关问题,包括进程池的创建模块,进程池函数等等内容,下面一起来看一下,希望对大家有帮助。

Python自动化实践之筛选简历Python自动化实践之筛选简历Jun 07, 2022 pm 06:59 PM

本篇文章给大家带来了关于Python的相关知识,其中主要介绍了关于简历筛选的相关问题,包括了定义 ReadDoc 类用以读取 word 文件以及定义 search_word 函数用以筛选的相关内容,下面一起来看一下,希望对大家有帮助。

归纳总结Python标准库归纳总结Python标准库May 03, 2022 am 09:00 AM

本篇文章给大家带来了关于Python的相关知识,其中主要介绍了关于标准库总结的相关问题,下面一起来看一下,希望对大家有帮助。

Python数据类型详解之字符串、数字Python数据类型详解之字符串、数字Apr 27, 2022 pm 07:27 PM

本篇文章给大家带来了关于Python的相关知识,其中主要介绍了关于数据类型之字符串、数字的相关问题,下面一起来看一下,希望对大家有帮助。

分享10款高效的VSCode插件,总有一款能够惊艳到你!!分享10款高效的VSCode插件,总有一款能够惊艳到你!!Mar 09, 2021 am 10:15 AM

VS Code的确是一款非常热门、有强大用户基础的一款开发工具。本文给大家介绍一下10款高效、好用的插件,能够让原本单薄的VS Code如虎添翼,开发效率顿时提升到一个新的阶段。

详细介绍python的numpy模块详细介绍python的numpy模块May 19, 2022 am 11:43 AM

本篇文章给大家带来了关于Python的相关知识,其中主要介绍了关于numpy模块的相关问题,Numpy是Numerical Python extensions的缩写,字面意思是Python数值计算扩展,下面一起来看一下,希望对大家有帮助。

python中文是什么意思python中文是什么意思Jun 24, 2019 pm 02:22 PM

pythn的中文意思是巨蟒、蟒蛇。1989年圣诞节期间,Guido van Rossum在家闲的没事干,为了跟朋友庆祝圣诞节,决定发明一种全新的脚本语言。他很喜欢一个肥皂剧叫Monty Python,所以便把这门语言叫做python。

See all articles

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)
2 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
2 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
2 weeks agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

EditPlus Chinese cracked version

EditPlus Chinese cracked version

Small size, syntax highlighting, does not support code prompt function

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool

SublimeText3 Linux new version

SublimeText3 Linux new version

SublimeText3 Linux latest version