How to use virtual enviroment for python

In some Linux distribution such as Debian, I cannot using pip install package directly for some reason. I still do not know why. So I learnt how to use virtual environment.

1
2
3
python3 -m venv path/to/venv
source path/to/venv/bin/activate
pip install package_name