W3docs

How can I install packages using pip according to the requirements.txt file from a local directory?

To install packages using pip from a local directory, you can use the -r option to specify the path to the requirements.txt file.

To install packages using pip from a local directory, you can use the -r option to specify the path to the requirements.txt file. For example, if the requirements.txt file is in the same directory as your Python script, you can use the following command:

Install packages using pip according to the requirements.txt file

pip install -r requirements.txt

<div class="alert alert-info flex not-prose"> Watch a course <span class="hidden md:block">Watch a video course </span> Python - The Practical Guide</div>

Alternatively, you can specify the path to the requirements.txt file if it is located in a different directory. For example:

Install packages using pip according to the requirements.txt file from a local directory?

pip install -r /path/to/requirements.txt

This will install all of the packages listed in the requirements.txt file.

You can also use the --upgrade option to upgrade the packages to the latest version if they are already installed:

Upgrade the Python packages to the latest version if they are already installed using pip

pip install --upgrade -r requirements.txt