Install multiple python packages at once using pip

This article will discuss two different ways to install multiple python packages in a single command using pip. These two ways are,

  • Using the raw pip install command.
  • Using requirements.txt with the pip install command

Let’s discuss them one by one,

Install multiple python packages in a single pip install command

We can pass the space-delimited list of package names to the pip install command. For example,

pip install pandas numpy flask pytz

It will install three packages i.e.

  • pandas
  • numpy
  • flask
  • pytz

To confirm that all the given packages have been installed or not, we can run this command to check all the installed packages i.e.

Advertisements
pip freeze

Output:

click==8.0.3
Flask==2.0.2
itsdangerous==2.0.1
Jinja2==3.0.2
MarkupSafe==2.0.1
numpy==1.21.2
pandas==1.3.3
python-dateutil==2.8.2
pytz==2021.3
six==1.16.0
Werkzeug==2.0.2

To install specific versions of multiple python packages in a single command, you can specify the version number along with package names in space separated list. For example,

pip install pandas==1.3.2 numpy==1.21.2 Flask==2.0.2

It will install all the specified versions of all the given python packages.

Install multiple python packages at once using requirements.txt

If you have an extensive list of packages to install, it is better to put them in a file named reqiurements.txt and install them in a single pip command. But command will be relatively shorter in this case. Let’s understand by an example,

Suppose you want to install four python packages, i.e., pandas, numpy, pytz, and flask. Then create requirements.txt with is content i.e.

Flask==2.0.2
numpy==1.21.2
pandas==1.3.2
pytz==2021.3

We have specified the version of packages too. The version number is optional, and if not provided, it will install the latest version of the package by default.

Now run the pip install command to install all the packages in requirements.txt i.e.

pip install -r requirements.txt

It will install all the packages specified in the requirements.txt

Summary

We learned two different ways to install multiple python packages in a single command.

Pandas Tutorials -Learn Data Analysis with Python

   

Are you looking to make a career in Data Science with Python?

Data Science is the future, and the future is here now. Data Scientists are now the most sought-after professionals today. To become a good Data Scientist or to make a career switch in Data Science one must possess the right skill set. We have curated a list of Best Professional Certificate in Data Science with Python. These courses will teach you the programming tools for Data Science like Pandas, NumPy, Matplotlib, Seaborn and how to use these libraries to implement Machine learning models.

Checkout the Detailed Review of Best Professional Certificate in Data Science with Python.

Remember, Data Science requires a lot of patience, persistence, and practice. So, start learning today.

Join a LinkedIn Community of Python Developers

Leave a Comment

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Scroll to Top