In this tutorial, I’m going to show you the basic how-to about search, install, remove and manage Python apps in Ubuntu, Debian, Fedora, and other Linux using pip package manager.
Linux has quite a few package managers. While
snap are most popular ways to install & manage apps, the popular Python programming language has a package installer called pip.
Pip is a package manager for Python apps. It connects to an online repository Python Package Index, allows to search and install from hundreds of thousands projects. It can also work with version control repositories (so far only Git, Mercurial, and Bazaar repositories).
Python is available in most Linux out-of-the-box, but pip may not. User may install it by firstly open terminal and run one of the commands below:
- Install pip in Ubuntu, Debian, Linux Mint, etc:
sudo apt install python3-pip
- For Fedora and CentOS, use command:
sudo dnf install python3-pip
- And, Arch Linux based systems can install it via command:
sudo pacman -S python-pip
If you install a specific Python version, it should also come along with pip installer.
Search, Install, Remove Python apps via pip:
In commands below, user may use pip3 instead of pip depends on your system edition. And, user may add sudo at beginning to install packages to system directories.
1. Search Python apps:
Pip has a search option. However, it always does not work! Since ‘search command queries is very resource intensive and too expensive for maintainers to always keep open to the public’, the API is disabled and will be deprecated.
For those want to search something, a “
pip-search” utility is an alternative from GitHub user
Firstly, install it via command:
pip install pip-search
Next, search something (e.g., game) via command:
~/.loca/bin/pip_search game if “.local/bin” is not in your PATH. And, it outputs something like this:
[email protected]:~$ pip_search game 🐍 https://pypi.org/search/?q=game 🐍 ┏━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━┳━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓ ┃ Package ┃ Version ┃ Released ┃ Description ┃ ┡━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━╇━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩ │ 📂 game │ 0.0.5 │ Sep 9, 2020 │ A web game emulator, not │ │ │ │ │ only can play games. │ │ │ │ │ Welcome to explore. │ │ 📂 game24 │ 1.0.1 │ Mar 27, 2015 │ A console application to │ │ │ │ │ play the 24 game │ │ 📂 eye-game │ 0.0.4 │ Jul 10, 2018 │ input: an image containing │ │ │ │ │ a human face; output: the │ │ │ │ │ eyeball direction │ │ 📂 market-game │ 0.0.7 │ Jul 8, 2019 │ Market game │ │... | |... | |... | └──────────────────────┴─────────┴──────────────┴────────────────────────────┘
2. Install Python apps:
To install an app (e.g.,
thonny IDE), simply run command with
pip install thonny
[email protected]:~$ sudo pip3 install thonny Collecting thonny Downloading thonny-3.3.14-py3-none-any.whl (1.6 MB) |████████████████████████████████| 1.6 MB 98 kB/s Collecting asttokens>=1.1 Downloading asttokens-2.0.5-py2.py3-none-any.whl (20 kB) Requirement already satisfied: setuptools>=33.1 in /usr/lib/python3/dist-packages (from thonny) (45.2.0) Collecting Send2Trash>=1.4 Downloading Send2Trash-1.8.0-py3-none-any.whl (18 kB) ... ...
It by default installs package executable files into “.local/bin” folder. It may not in user’s PATH, so need to run “
~/.local/bin/thonny” to run the app.
To install into system folder (usually “/usr/local/bin“), add
sudo at beginning so the command will be:
sudo pip install thonny
After that, run
thonny will launch the app.
NOTE: pip does not recommend to run as "sudo", as it may result in broken permissions and conflicting behavior with the system package manager.
And, user may upgrade a Python app via command:
pip install --upgrade thonny
There are a few other flags, e.g.,
3. List installed Python apps:
flatpak package manager, user may list installed Python apps using command:
And, tell an app details (e.g.,
thonny in command below) including package version, description, homepage, author, contact, installed location, and dependencies.
pip show thonny
[email protected]:~$ pip show thonny Name: thonny Version: 3.3.14 Summary: Python IDE for beginners Home-page: https://thonny.org Author: Aivar Annamaa and others Author-email: [email protected] License: MIT Location: /home/ji/.local/lib/python3.8/site-packages Requires: pyserial, docutils, mypy, Send2Trash, jedi, asttokens, pylint, setuptools
4. Remove Python apps via pip:
Similar to other package manager, use may remove a package (
thonny package for example) via command:
pip uninstall thonny
sudo at beginning if you were installing it to system directory.
[email protected]:~$ sudo pip uninstall thonny Found existing installation: thonny 3.3.14 Uninstalling thonny-3.3.14: Would remove: /usr/local/bin/thonny /usr/local/lib/python3.8/dist-packages/thonny-3.3.14.dist-info/* /usr/local/lib/python3.8/dist-packages/thonny/* Proceed (Y/n)?
Pip does not remove useless dependency libraries. User may install the pip-autoremove package. Then use command below to remove a package along with its dependencies.
In the tutorial I’ve taught the basic usage about how to install, remove, list, search Python app packages via pip. For more, run
man pip in terminal or see the official documentation.