Project Dependency 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 project in Python, you must have virtualenv and pip installed on your computer.
Verify if virtualenv is installed using the command below:
Verify if pip3 is installed using the command below:
If they are installed then both of the above commands should return their versions respectively. Otherwise you can use this guide to install them.
virtualenv env --python=python3.8
A new env folder will get created inside the project folder. The env directory will contain files and folders such as bin and lib.
If the virtual environment is activated successfully, you will see that the next line of the terminal starting with the (env).
Whenever you need to install dependencies in your project, you can install them by using the pip command from within the virtualenv activated terminal. For example, the pip command below installs pure-Python MySQL client library .
pip3 install PyMySQL
pip3 freeze > requirements.txt
Note: you must generate the requirements.txt file from inside the activated virtual environment terminal.
pip3 install -r requirements.txt