Application Dependencies Management is the process of managing dependencies of a project which are available in the form of reusuable functions in libraries.
To maintain dependencies of a Python project, you must have the following tools installed on your computer:
In this tutorial, we will create a Python project, create a virtual environment for the project, and install some dependencies such as MySQL client library for the project.
Follow the steps below to learn how to manage dependencies for a Python project:
virtualenv env --python=python3.8
Here, env is the name of the virtual environment for this project. The above command creates env folder in the root directory of the project. This env folder contains files and folders such as bin and lib.
On successful activation of your project virtual environment, you will see that the next line of the terminal starting with the (env).
Here is an example of pip command that installs MySQL client library in the virtual environment:
pip3 install PyMySQL
The requirements.txt file in Python is typically used for storing information about all the libraries and packages required to run the project.
To generate a requirements.txt file, activate the virtual environment first and then execute the following command:
pip3 freeze > requirements.txt
To install dependencies from the requirements.txt file, activate the virtual environment and run the following command:
pip3 install -r requirements.txt