Easily learn how to use pip in Python

Technical Q&A

This method comes from the sharing of small partners in the technical group. If you want to join, follow the steps below

At present, a technical exchange group has been opened, and the group has more than 3,000 people. The best way to remark when adding is: source + interest direction, which is convenient to find like-minded friends

Method ①, add WeChat ID: dkl88191, remarks: from CSDN + technical exchange
Method ②, WeChat search public number: Python learning and data mining, background reply: add group + CSDN

1. Brief introduction

pip is a Python package management tool. This tool provides functions for finding, downloading, installing and uninstalling Python packages. Now all the packages you use are either built-in or installed through pip. Python 2.7.9+ or Python 3.4+ comes with the pip tool.

Give the pip official website link: pip official website .
insert image description here

2. Download and install

You can use the command pip --version to determine whether it is installed:

insert image description here

If you haven't installed it yet, you can install it using the following two methods:

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

py -m ensurepip --upgrade

2. You can also download a Python script to install pip using the command line bootstrap logic.

  1. Download the script to your Python folder
  2. win+cmd to open the terminal, switch to the directory of your script
  3. Enter the command Enter
 py get-pip.py

3. The most commonly used commands

1. Display version and path

pip --version
insert image description here

2. Get help


pip --help
insert image description here

3. Upgrade pip

pip install -U pip

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

4. Installation package

pip install SomePackage # latest version
pip install SomePackage==1.0.4 # specified version
pip install 'SomePackage>=1.0.4' # minimum version

For example, if I want to install sklearn, enter pip install sklearn, and the latest version of the package will be installed

insert image description here

5. Upgrade package

pip install --upgrade SomePackage

升级指定的包,通过使用==, >=, <=, >, < 来指定一个版本号。

6. Uninstall the package

pip uninstall SomePackage

7. Search packages

pip search SomePackage

8. Display installation package information

pip show SomePackage

insert image description here

9. List installed packages

pip list

insert image description here

10. View the details of the specified package

pip show -f SomePackage

insert image description here

Guess you like

Origin blog.csdn.net/m0_59596937/article/details/127180687