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.
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
-
Pandas Tutorial Part #1 - Introduction to Data Analysis with Python
-
Pandas Tutorial Part #2 - Basics of Pandas Series
-
Pandas Tutorial Part #3 - Get & Set Series values
-
Pandas Tutorial Part #4 - Attributes & methods of Pandas Series
-
Pandas Tutorial Part #5 - Add or Remove Pandas Series elements
-
Pandas Tutorial Part #6 - Introduction to DataFrame
-
Pandas Tutorial Part #7 - DataFrame.loc[] - Select Rows / Columns by Indexing
-
Pandas Tutorial Part #8 - DataFrame.iloc[] - Select Rows / Columns by Label Names
-
Pandas Tutorial Part #9 - Filter DataFrame Rows
-
Pandas Tutorial Part #10 - Add/Remove DataFrame Rows & Columns
-
Pandas Tutorial Part #11 - DataFrame attributes & methods
-
Pandas Tutorial Part #12 - Handling Missing Data or NaN values
-
Pandas Tutorial Part #13 - Iterate over Rows & Columns of DataFrame
-
Pandas Tutorial Part #14 - Sorting DataFrame by Rows or Columns
-
Pandas Tutorial Part #15 - Merging or Concatenating DataFrames
-
Pandas Tutorial Part #16 - DataFrame GroupBy explained with examples
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.