[Python] What is pip? Explain the command list and how to use it with actual examples

[Python] What is pip? Explain the command list and how to use it with actual examples

I was curious about ** pip ** used when installing modules and packages with python, so I summarized it.

Easy version control and upgrades. It is quite convenient if you know how to add it.

table of contents

  1. [What is pip? ](What is # 1-pip)
  2. [What you can do with pip](# 2-What you can do with pip)
  3. [Pip main command list quick reference table](# 3-pip main command list quick reference table)
  4. [Install](# 4-Install command)
  5. [Normal installation](# 4-1-Normal installation)
  6. [Upgrade](# 4-2-Upgrade)
  7. [Install by specifying the version](# 4-3-Install by specifying the version)
  8. [Check Version](# 5-Check Version)
  9. [Pip list](# 5-1 pip-list)
  10. [Pip freeze](# 5-2 pip-freeze)
  11. [Check only those that are not the latest version](# 5-3-Check only those that are not the latest version)
  12. [Check pip version](# 5-4-Check version of pip)
  13. [Check Package Version](# 5-5-Check Package Version)
  14. [Download](# 6-Download)
  15. [Get Help](# 7-Get Help)
  16. [List of commands and options for pip](# 7-1-List of commands and options for pip)
  17. [Help for each command](# 7-2-Help for each command)
  18. [Difference between pip and pip3](# 8-Difference between pip and pip3)

## 1. What is pip? ** python official ** package management system. It's in the installed python.

Abbreviation for Pip javax Packages (or Python). How to read is pip.

You can install and uninstall packages officially registered in python.

** ** The python package is managed by PyPI. └ Abbreviation for Python Package Index └ Name: Pai Pai └ Official page: https://pypi.org/

It is pip to access PyPI with a command and install files.


## 2. What you can do with pip

Of modules and packages

--Installation

Such


## 3. A quick reference table of pip's main commands |command|Contents| |:--|:--| |pip install package name|Package installation| | pip install -U package name|upgrade| | pip install --update package name|upgrade| |pip install package name==version|Installation (version specified)| | pip list |List of installed package names and versions| | pip freeze |List of installed package names and versions| | pip list --outdate |Show only those that are not the latest version| | pip -V |View pip version information| |pip show package name|Display version information etc.| |pip download package name|DL the latest file(Do not install) | |pip help|View a list of pip's main commands and options| |pip command-h|View command content and options|
> * About commands ・ If the path is passed: `pip` -If the path does not pass: `py -m pip` └ Same as "python -m pip"

The case is a description when the path passes.


## 4. Installation command

4-1. Normal installation 4-2. Upgrade 4-3. Install by specifying the version (can be downgraded)


### 4-1. Normal installation `pip install package name` └ Example "pip install selenium"

If it is already installed, "Requirement already satisfied:" is displayed.


### 4-2. Upgrade `pip install -U package name` `pip install --upgrade package name` └ Example 1: "pip install -U selenium" └ Example 2: "pip install -U pip" (Upgrade pip to the latest version)

The option can be either "-U" or "--update".

If it is already the latest, "Requirement already up-to-date:" is displayed.


### 4-3. Install by specifying the version `pip install package name == version` └ Example: "pip install dash == 1.9.0"

You can also install (downgrade) the old version.


## 5. Check the version

** ▼ Check all together ** 5-1. pip list 5-2. pip freeze 5-3. Check only those that are not the latest version

** ▼ Check individually ** 5-4. Check the version of pip 5-5. Check the package version


#### Check all together 5-1.pip list Display package name and version in list format.

pip list

> pip list
Package              Version
-------------------- ----------
attrs                19.3.0
backcall             0.1.0
bleach               3.1.0
certifi              2019.11.28
chardet              3.0.4
Click                7.0
colorama             0.4.3
dash                 1.9.0
dash-core-components 1.8.0
dash-html-components 1.0.2
・
・
・

5-2.pip freeze The basic function is the same as "pip list". The display format is different. freeze can specify the display method (likely)

> pip freeze
attrs==19.3.0
backcall==0.1.0
bleach==3.1.0
certifi==2019.11.28
chardet==3.0.4
Click==7.0
colorama==0.4.3
dash==1.9.0
dash-core-components==1.8.0
dash-html-components==1.0.2
・
・
・

### 5-3. Check only those that are not the latest version

pip list --outdate Shows the package name, currently installed version, and latest version.

> pip list --outdate
Package              Version Latest Type
-------------------- ------- ------ -----
bleach               3.1.0   3.1.3  wheel
Click                7.0     7.1.1  wheel
dash                 1.9.0   1.9.1  sdist
dash-core-components 1.8.0   1.8.1  sdist
dash-table           4.6.0   4.6.1  sdist
decorator            4.4.1   4.4.2  wheel
idna                 2.8     2.9    wheel
・
・
・

5-4. Check the version of pip

pip -V └ "-V" is uppercase.

Show version and destination path.

> pip -V
pip 20.0.2 from c:\users\appdata\local\programs\python\lib\site-packages\pip (python 3.8)

### 5-5. Check the package version `pip show package name` └Example: "pip show selenium"

You can see the version information, official URL, creator, save destination path, etc.

> pip show selenium
Name: selenium
Version: 3.141.0
Summary: Python bindings for Selenium
Home-page: https://github.com/SeleniumHQ/selenium/
Author: UNKNOWN
Author-email: UNKNOWN
License: Apache 2.0
Location: c:\users\appdata\local\programs\python\lib\site-packages
Requires: urllib3
Required-by:

## 6. Download `pip download package name` └Example: "pip download selenium"

It can be used when you want to download the latest file without installing it.


## 7. Display help 7-1. List of pip commands and options 7-2. Help for each command
### 7-1. List of pip commands and options `pip help`
See a list of commands and options
> pip help

Usage:
  pip <command> [options]

Commands:
  install                     Install packages.
  download                    Download packages.
  uninstall                   Uninstall packages.
  freeze                      Output installed packages in requirements format.
  list                        List installed packages.
  show                        Show information about installed packages.
  check                       Verify installed packages have compatible dependencies.
  config                      Manage local and global configuration.
  search                      Search PyPI for packages.
  wheel                       Build wheels from your requirements.
  hash                        Compute hashes of package archives.
  completion                  A helper command used for command completion.
  debug                       Show information useful for debugging.
  help                        Show help for commands.

General Options:
  -h, --help                  Show help.
  --isolated                  Run pip in an isolated mode, ignoring environment
                              variables and user configuration.
  -v, --verbose               Give more output. Option is additive, and can be used up
                              to 3 times.
  -V, --version               Show version and exit.
  -q, --quiet                 Give less output. Option is additive, and can be used up
                              to 3 times (corresponding to WARNING, ERROR, and
                              CRITICAL logging levels).
  --log <path>                Path to a verbose appending log.
  --proxy <proxy>             Specify a proxy in the form
                              [user:passwd@]proxy.server:port.
  --retries <retries>         Maximum number of retries each connection should attempt
                              (default 5 times).
  --timeout <sec>             Set the socket timeout (default 15 seconds).
  --exists-action <action>    Default action when a path already exists: (s)witch,
                              (i)gnore, (w)ipe, (b)ackup, (a)bort.
  --trusted-host <hostname>   Mark this host or host:port pair as trusted, even though
                              it does not have valid or any HTTPS.
  --cert <path>               Path to alternate CA bundle.
  --client-cert <path>        Path to SSL client certificate, a single file containing
                              the private key and the certificate in PEM format.
  --cache-dir <dir>           Store the cache data in <dir>.
  --no-cache-dir              Disable the cache.
  --disable-pip-version-check
                              Don't periodically check PyPI to determine whether a new
                              version of pip is available for download. Implied with
                              --no-index.
  --no-color                  Suppress colored output
  --no-python-version-warning
                              Silence deprecation warnings for upcoming unsupported
                              Pythons.

### 7-2. Help for each command `pip command -h` └Example: "pip install -h"

You can check the usage and options of each command.

> pip install -h

Usage:
  pip install [options] <requirement specifier> [package-index-options] ...
  pip install [options] -r <requirements file> [package-index-options] ...
  pip install [options] [-e] <vcs project url> ...
  pip install [options] [-e] <local project path> ...
  pip install [options] <archive url/path> ...

Description:
  Install packages from:

  - PyPI (and other indexes) using requirement specifiers.
  - VCS project urls.
  - Local project directories.
  - Local or remote source archives.

  pip also supports installing from "requirements files", which provide
  an easy way to specify a whole environment to be installed.

Install Options:
  -r, --requirement <file>    Install from the given requirements file. This option
・
・
・

## 8. Difference between pip and pip3

In pip, pip commands such as "pip2" and "pip3" are prepared for each version of python.


** ■ If python versions are not mixed ** "Pip" is the same as the corresponding version of pip. python3 series only: "pip" = "pip3" python2 series only: "pip" = "pip2"
** ■ When versions are mixed ** python3 series: "pip3" python2 series: "pip", "pip2"
[Return to top](#pythonpip is module package installation removal and version confirmation)

Recommended Posts

[Python] What is pip? Explain the command list and how to use it with actual examples
[Python] What is a tuple? Explains how to use without tuples and how to use it with examples.
What is pip and how do you use it?
How to use is and == in Python
How to use Python with Jw_cad (Part 2 Command explanation and operation)
[Python] What is a slice? An easy-to-understand explanation of how to use it with a concrete example.
[Introduction to Python] What is the difference between a list and a tuple?
[Algorithm x Python] How to use the list
How to use the grep command and frequent samples
[Python] How to use list 1
It is easy to execute SQL with Python and output the result in Excel
[Introduction to statistics] What kind of distribution is the t distribution, chi-square distribution, and F distribution? A little summary of how to use [python]
Python: How to use async with
[Python] How to use list 3 Added
How to use FTP with Python
If you don't know it, it's dangerous. Carefully explain how to use the xargs command
Recursively get the Excel list in a specific folder with python and write it to Excel.
How to give and what the constraints option in scipy.optimize.minimize is
How to use the asterisk (*) in Python. Maybe this is all? ..
[Python] Explains how to use the format function with an example
How to deal with errors when installing Python and pip with choco
How to utilize Python with Jw_cad (Part 1 What is external transformation)
[Introduction to Python] How to use the Boolean operator (and ・ or ・ not)
Is it deprecated to use pip directly?
How to install and use pandas_datareader [Python]
[Pandas] What is set_option [How to use]
[Linux] How to use the echo command
How to use the Linux grep command
python: How to use locals () and globals ()
How to use CUT command (with sample)
How to use Python zip and enumerate
Summary of how to use Python list
[Python] Explains how to use the range function with a concrete example
[Introduction to Python] How to sort the contents of a list efficiently with list sort
[Python] How to use the enumerate function (extract the index number and element)
Read CSV file with Python and convert it to DataFrame as it is
[Introduction to Python] What is the method of repeating with the continue statement?
How to input a character string in Python and output it as it is or in the opposite direction.
How to use the C library in Python
What is the difference between `pip` and` conda`?
Specify the Python executable to use with virtualenv
The easiest way to use OpenCV with python
What are you comparing with Python is and ==?
How to use tkinter with python in pyenv
[Python] How to use hash function and tuple.
How to install Cascade detector and how to use it
How to get started with the 2020 Python project (windows wsl and mac standardization)
Tips for those who are wondering how to use is and == in Python
Why Docker is so popular. What is Docker in the first place? How to use
How to use Service Account OAuth and API with Google API Client for python
If you try to install Python2 pip after installing Python3 pip and it is rejected
How to get a list of files in the same directory with python
python: Tips for displaying an array (list) with an index (how to find out what number an element of an array is)
I tried to explain how to get the article content with MediaWiki API in an easy-to-understand manner with examples (Python 3)
[Python] [Django] How to use ChoiceField and how to add options
How to use pip, a package management system that is indispensable for using Python
How to delete the specified string with the sed command! !! !!
[Introduction to Python] How to iterate with the range function?
How to use the grep command to recursively search directories and files to a specified depth
Explain in detail how to make sounds with python
How to identify the element with the smallest number of characters in a Python list?