-
Verify if Python and 'pip' are installed on the machine:
python --version
. If not install:- Python
sudo apt install python3
- 'pip':
sudo apt install python3-pip
- Python
-
Install virtual environment package:
- 'venv' virtual environment:
sudo apt install python3-venv
- 'virtuelenv' virtual environment:
sudo apt install python3-virtualenv
- 'venv' virtual environment:
-
Navigate to project directory
cd python-project
and create virtual environment:- For 'venv' virtual environment:
python3 -m venv venv
- For 'virtualenv' virtual environment:
virtualenv venv
- For 'venv' virtual environment:
-
Activate the environment:
source venv/bin/activate
-
Add libraries and create requirements.txt file
pip 'libraries to install'
pip freeze > requirements.txt
(create the requirements.txt file enumerating the installed packages)
-
Deactivate the environment:
deactivate