Table of Contents
PIP is a Python package manager allowing you to install and manage packages not part of the Python standard library. All Python packages are hosted on an online repository called Python Package Index. PIP connects this repository, then downloads and installs Python packages to your system. PIP provides a simple and easiest way to install locally user-defined projects using a setup.py file. PIP is a command line utility that helps you to install, reinstall, or uninstall packages with a single command.
This post will show you how to install and manage Python packages using PIP on Fedora.
Install PIP on Fedora
By default, the PIP package is not installed on Fedora, so you will need to install it first. You can install it using the following command.
dnf install python3-pip
Once the PIP package is installed, you can verify the PIP version with the following command.
pip3 --version
Output.
pip 21.0.1 from /usr/lib/python3.9/site-packages/pip (python 3.9)
It is also recommended to upgrade PIP to the latest version. You can upgrade it with the following command.
pip3 install --upgrade pip
Output.
Requirement already satisfied: pip in /usr/lib/python3.9/site-packages (21.0.1) Collecting pip Downloading pip-23.1.2-py3-none-any.whl (2.1 MB) |████████████████████████████████| 2.1 MB 12.6 MB/s Installing collected packages: pip Successfully installed pip-23.1.2
Now, verify the PIP version again with the following command.
pip3 --version
Output:
pip 23.1.2 from /usr/local/lib/python3.9/site-packages/pip (python 3.9)
To see all available options of the PIP command, run the following command.
pip3 --help
Output.
Usage: pip3[options] Commands: install Install packages. download Download packages. uninstall Uninstall packages. freeze Output installed packages in requirements format. inspect Inspect the python environment. 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. cache Inspect and manage pip's wheel cache. index Inspect information available from package indexes. 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.
Manage Packages with PIP
PIP provides a simple and easiest way to install and manage Python packages via the command line.
For example, to install the scrapy package, run the following command.
pip3 install scrapy
To verify the package information, run the following command.
pip3 show scrapy
Output:
Name: Scrapy Version: 2.8.0 Summary: A high-level Web Crawling and Web Scraping framework Home-page: https://scrapy.org Author: Scrapy developers Author-email: [email protected] License: BSD Location: /usr/local/lib/python3.9/site-packages Requires: cryptography, cssselect, itemadapter, itemloaders, lxml, packaging, parsel, protego, PyDispatcher, pyOpenSSL, queuelib, service-identity, setuptools, tldextract, Twisted, w3lib, zope.interface Required-by:
To get a list of all available packages, run the following command.
pip3 list
Output.
Package Version ------------------ --------- argcomplete 1.12.0 attrs 23.1.0 Automat 22.10.0 certifi 2022.12.7 cffi 1.15.1 charset-normalizer 3.1.0 constantly 15.1.0 cryptography 40.0.2 cssselect 1.2.0 dbus-python 1.2.16 decorator 4.4.2 distro 1.5.0 filelock 3.12.0 gpg 1.15.1 hyperlink 21.0.0 idna 3.4 incremental 22.10.0 itemadapter 0.8.0 itemloaders 1.1.0 jmespath 1.0.1 libcomps 0.1.15 lxml 4.9.2 nftables 0.1 ntpsec 1.2.0 packaging 23.1 parsel 1.8.1 pexpect 4.8.0
To list all outdated packages, run the following command.
pip3 list --outdated
Output:
Package Version Latest Type --------------- ------- ------------ ----- argcomplete 1.12.0 3.0.8 wheel dbus-python 1.2.16 1.3.2 sdist decorator 4.4.2 5.1.1 wheel distro 1.5.0 1.8.0 wheel libcomps 0.1.15 0.1.15.post1 wheel ptyprocess 0.6.0 0.7.0 wheel PyGObject 3.40.1 3.44.1 sdist python-augeas 0.5.0 1.1.0 sdist python-dateutil 2.8.1 2.8.2 wheel setuptools 53.0.0 67.7.2 wheel six 1.15.0 1.16.0 wheel slip 0.6.4 20191113 sdist systemd-python 234 235 sdist
To install any package, run the following command.
pip3 uninstall scrapy
Output:
Found existing installation: Scrapy 2.8.0 Uninstalling Scrapy-2.8.0: Would remove: /usr/local/bin/scrapy /usr/local/lib/python3.9/site-packages/Scrapy-2.8.0.dist-info/* /usr/local/lib/python3.9/site-packages/scrapy/* Proceed (Y/n)? Y Successfully uninstalled Scrapy-2.8.0
Conclusion
This post explained how to install and manage Python packages with PIP. You can now use PIP in your development environment to install any Python dependency. You can now try PIP on VPS hosting from Atlantic.Net!