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.
Pip:
Linux has quite a few package managers. While apt
, dnf
, pacman
, flatpak
and 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).
Install Pip:
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 @victorgarric
.
Firstly, install it via command:
pip install pip-search
Next, search something (e.g., game) via command:
pip_search game
Or, use ~/.loca/bin/pip_search game
if “.local/bin” is not in your PATH. And, it outputs something like this:
merilyn@focal:~$ 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 install
flag:
pip install thonny
merilyn@focal:~$ 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., --force-reinstall
and --target
.
3. List installed Python apps:
Like apt
and flatpak
package manager, user may list installed Python apps using command:
pip list
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
merilyn@focal:~$ 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
Add sudo
at beginning if you were installing it to system directory.
merilyn@focal:~$ 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.
pip-autoremove <package_name>
Summary:
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.
Recent Comments