One article to complete the installation and use of pip in Python

WBOY
Release: 2022-06-14 19:11:38
forward
7499 people have browsed it

This article brings you relevant knowledge about python, which mainly introduces issues related to the installation and use of pip, including upgrading pip, displaying installation package information, and viewing specified packages. Let’s take a look at the detailed information and so on. I hope it will be helpful to everyone.

One article to complete the installation and use of pip in Python

Recommended learning: python video tutorial

1. Brief introduction

pip is a Python package management tool. This tool provides the functions of searching, downloading, installing and uninstalling Python packages. All the packages you use now either come with them or are installed through pip. Python 2.7.9 or Python 3.4 or above comes with the pip tool.

One article to complete the installation and use of pip in Python

2. Download and install

You can use the command pip --version to determine whether it has been installed:
One article to complete the installation and use of pip in Python
If you still If it is not installed, you can use the following two methods to install it:

1. Python comes with a ensurepip module, which can install pip in the Python environment. Enter the following command in cmd

py -m ensurepip --upgrade
Copy after login

2. You can also download a Python script and use the command line boot logic to install pip.

  1. Download the script to your Python folder
  2. win cmd to open the terminal and switch to the directory of your script
  3. Enter the command and press Enter
 py get-pip.py
Copy after login

3. The most commonly used commands

1. Display version and path

pip --version
One article to complete the installation and use of pip in Python

2. Get help

pip --help
One article to complete the installation and use of pip in Python

3. Upgrade pip

pip install -U pip

ps:升级需谨慎,经常看到pip提醒升级,然后输入命令回车,系统开始下载最新版安装包,
准备安装前卸载了旧版pip,然后新版又报错无法安装,只好又重装。
Copy after login

4. Installation package

pip install SomePackage #The latest version
pip install SomePackage==1.0.4 #Specify the version
pip install 'SomePackage>=1.0.4' #The smallest version

For example, I want to install sklearn , enter pip install sklearn, the latest version of the package
One article to complete the installation and use of pip in Python

5, upgrade package

pip install --upgrade SomePackage

升级指定的包,通过使用==, >=, , <h2>6. Uninstall package</h2><p><strong><span style="color:blue">pip uninstall SomePackage</span></strong></p><h2>7. Search package</h2><p><strong><span style="color:blue">pip search SomePackage</span></strong></p><h2>8. Display installation package information</h2><p><strong><span style="color:blue">pip show SomePackage</span></strong><br><img src="https://img.php.cn/upload/article/000/000/067/242888d8bfa43019edc970c8ab5edb0f-5.png" alt="One article to complete the installation and use of pip in Python"></p><h2>9. List installed packages</h2><p><strong><span   style="max-width:90%">pip list</span></strong><br><img src="https://img.php.cn/upload/article/000/000/067/7361c4a9e66a41cb77df500fca51e01a-6.png" alt="One article to complete the installation and use of pip in Python"></p><h2>10. View detailed information of the specified package</h2><p><strong>##pip show -f SomePackage<span   style="max-width:90%"></span></strong><br><img src="https://img.php.cn/upload/article/000/000/067/7361c4a9e66a41cb77df500fca51e01a-7.png" alt="One article to complete the installation and use of pip in Python"></p>Recommended learning:<p> python video tutorial<a href="https://www.php.cn/course/list/30.html" target="_blank"></a></p>
Copy after login

The above is the detailed content of One article to complete the installation and use of pip in Python. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:csdn.net
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template