Using PIP to Install and Manage Python Packages
Now that you have PIP installed and upgraded on your Ubuntu system, let's explore how to use it to install, manage, and maintain your Python packages.
Installing Python Packages
To install a Python package using PIP, you can run the following command:
python3 -m pip install <package_name>
Replace <package_name>
with the name of the package you want to install. For example, to install the popular requests
library, you would use:
python3 -m pip install requests
Upgrading Python Packages
If you need to upgrade an existing Python package to a newer version, you can use the following command:
python3 -m pip install --upgrade <package_name>
This will update the specified package to the latest available version.
Listing Installed Packages
To view a list of all the Python packages installed on your system, you can use the following command:
python3 -m pip list
This will display a table of all the installed packages, along with their current versions.
Searching for Packages
If you're looking for a specific Python package, you can search for it on the Python Package Index (PyPI) using the following command:
python3 -m pip search <package_name>
This will return a list of packages matching the search query, along with a brief description of each package.
By mastering these basic PIP commands, you'll be able to efficiently install, manage, and maintain the Python packages required for your projects, ensuring a smooth and productive development experience.