Always create the Python virtual environment in the same directory as the project. This ensures that the virtual environment is not shared between projects. We will use the virtual environment to install the required packages for the project. This ensures that the project is not dependent on system-wide packages.
To create a virtual environment, run the following command in the terminal:
python -m venv virtual_environment_name
python3 -m venv virtual_environment_name
To activate the virtual environment, run the following command in the terminal:
virtual_environment_name\Scripts\activate
source virtual_environment_name/bin/activate
In JavaScript, there is a file called package.json
where all the dependencies of the project are defined. In Python, we use a requirements.txt
file to define all the dependencies of the project. This file is used by the pip
tool to install all the dependencies.
Simply list the dependencies in the requirements.txt
file and run the following command to install them:
pip install -r requirements.txt