Python 2

virtualenv venv2
source venv2/bin/activate
pip install pytest

Python 3

virtualenv venv3 -p python3
source venv3/bin/activate
pip install pytest

Python 3 Debian/Ubuntu

apt-get install python3-pytest

Python 3 RedHat/Centos

yum install python3-pytest