Send by LINE
B! Bookmarks in Hate-bu
Bookmarks in Pocket
RSS feeds

Python pip: How to use package management

Other language site
No available translations found
Google Translate
python logo

Python's pip is a command tool to manage packages.

The package is an extension program of various additional functions prepared in python. By installing this package as needed, you can efficiently build a program that implements the desired function in Python.

I will show you how to use the pip command.

What is a Python package?

Python can add a variety of functions. These functions are published in GitHub etc. in the unit of package.

The tool to manage that package is pip. You should think of it like php's composer, Ruby's gem.

Language Package Management
Python pip
PHP composer
Ruby gem

Use the pip command to add, update, and delete packages.

Also, in recent years, Django and other frameworks can also be easily installed using this pip.

When handling Python, you should probably think that pip is always used.

Difference between pip and pip3

There is no difference when using only version 3 lines.

In an environment where version 2 and version 3 coexist, there is a difference that pip manipulates version 2 lines and pip3 operates packages of version 3 lines.

The pip command is installed as a standard in Python since version 2.7. In particular, you do not need to install the pip command.

First of all, I will introduce five commands that are the minimum necessary to install a package.

How to install packages

python -m pip install 'package_name'

Use the "install" command to install the package.

How to update packages

python -m pip install -U 'package_name'

Use the "install" command with the "-U" ("--upgrade") option to update the package.

How to uninstall packages

python -m pip uninstall 'package_name'

Use the "uninstall" command to uninstall the package. The installation / uninstallation command is "install" / "uninstall" so it is easy to remember.

How to display installed package list

python -m pip list

Displays the list of installed packages.

How to check package update

python -m pip list -o

Check if package update is possible.

Pip subcommand


python -m pip install 'package_name'

Install / upgrade the package.


 -U, --upgrade
python -m pip install -U 'package_name'

Upgrade the package.

python -m pip install --upgrade pip

Upgrade the pip command itself.

python -m pip install -r import.txt

Install packages collectively from the package list file (import.txt) created with "freeze" command.


python -m pip uninstall 'package_name'

Uninstall the package.


python -m pip list

The list of installed packages is displayed.


python -m pip list -o

Displays updatable packages.

python -m pip list -u

Displays the package containing the latest version.

python -m pip list -e

Display the installed package with "install - e".

python -m pip list -l

In the "virtualenv" environment, packages installed on the system are not displayed.

python -m pip list --pre

Beta version is also displayed.


python -m pip freeze > output.txt

It outputs the currently installed package in a format that can be installed collectively with "pip install - r".


python -m pip show 'package_name'

Displays detailed information on the package.


python -m pip check

Check package dependencies.


python -m pip help

Displays help of pip command.

Leave a Reply