4 pip Commands You Must Know To Master Your Python Workflow

M Shehzen
Geek Culture
Published in
5 min readJan 4, 2023

--

Pip is a crucial tool for any Python developer. It allows you to easily install, update, and manage packages in the Python ecosystem. With pip, you can easily access a vast array of libraries and frameworks that can significantly enhance your projects.

In this post, we will be highlighting 4 essential pip commands that can make your life as a developer much easier. These commands can save you time and effort by automating various tasks and streamlining your workflow. Whether you are a seasoned Python developer or just starting, these commands are sure to come in handy.

Command 1: pip install

pip install is a command in Python that allows you to install packages from the Python Package Index (PyPI). It is the most used pip command.

The pip install command downloads the package from the PyPI repository and installs it on your system. It is useful because it allows you to easily add new functionality to your Python installation by installing pre-built, third-party packages. Now there are various ways with which you can install packages. Let us see some of them.

Here are some examples of how pip install can be used:

  1. To install a package by name, you can use the following command: pip install package_name
  2. To install a specific version of a package, you can use the following command: pip install package_name==version
  3. To install a package and all of its dependencies, you can use the following command: pip install package_name[all]
  4. To install a package from a specific repository (e.g., a fork of the original package), you can use the following command: pip install git+https://github.com/user/package_name.git

Command 2: pip freeze

pip freeze is a command that allows you to view all the packages and their respective versions that are currently installed in your Python environment. This is useful when you want to track the packages and versions that you have installed, or when you want to share the packages that you are using with others.

Here is how pip freeze can be used: pip freeze

Just two words and its output looks like this:

Sometimes, just showing is not enough. You need the list of all the packages in a text file. We can do that also by creating a requirements.txt file. The name is your choice but requirements.txt is followed by all python programmers to get an idea of what this file contains. So it is a good thing to name yours too the same.

So it is often useful to create a requirements.txt file that lists all the packages and their versions that the project depends on. This makes it easier for others to set up the project and ensures that the same package versions are used across different environments. To create a requirements.txt file, you can use the pip freeze > requirements.txt command, which writes the output of pip freeze to a file named requirements.txt.

Overall, pip freeze is a useful command that can help you track and share the packages and versions you are using in your Python projects.

Command 3: pip list

pip list is a command that allows you to view the packages that are currently installed in your Python environment. This is useful when you want to see which packages are installed and their respective versions. For Example:

Viewing all installed packages: By default, the pip list command displays a list of all the packages that are currently installed in your environment, along with their respective versions. This can be useful when you want to see which packages are installed and their versions, or when you want to check if a specific package is installed.

Although, the output is similar to the pip freeze, here the output is more formatted and easy to read. There are other uses of pip list also.

Filtering the list to show only outdated packages: The pip list command also allows you to filter the list to show only outdated packages. To do this, you can use the —outdated flag, which displays only the packages that have a newer version available. This can be useful when you want to quickly see which packages need to be updated. The output of this pip command along with --outdated looks like this:

From the above output, it is easy for us to know which package needs to be updated and which package is far behind. Keep in mind, it will only show outdated ones and not all the installed packages. There are many use cases of pip list, but those discussed here are sufficient for us.

Overall, pip list is a useful command that allows you to view the packages that are installed in your environment and filter the list based on various criteria. It can save you time and effort by allowing you to quickly see which packages are installed and which ones need to be updated.

Command 4: pip uninstall

pip uninstall is a command that allows you to remove a package from your Python environment. This is useful when you want to remove a package that is no longer needed or when you want to upgrade to a newer version of a package.

pip uninstall can be used in the following way: pip uninstall package_name

The pip uninstall command also allows you to remove multiple packages at once. To do this, you can specify the names of the packages you want to remove as arguments to the command. For example,

The above command will remove the packages with the specified names.

pip uninstall is a useful command that allows you to remove packages from your environment. It can save you time and effort by allowing you to easily remove unnecessary packages or upgrade to newer versions of packages.

Final Words

pip is an essential tool for any Python developer. It allows you to easily install, update, and manage packages in the Python ecosystem, which can significantly enhance your projects.

In this post, we highlighted 5 essential pip commands that can make your life as a developer much easier.

I encourage you to try out these commands and see how they can make your workflow more efficient. Whether you are a seasoned Python developer or just starting, these commands are sure to come in handy.

Thank you for reading. You can follow me on Twitter and also give follow me on Medium to stay up to date with my Content. Have a nice day.

--

--

M Shehzen
Geek Culture

I am student, Blogger and trying to teach and learn from others. Happy learning and Happy reading.