# Basic syntax:
pip list | grep packagename # or:
pip3 list | grep packagename
# Where:
# - pip/pip3 list lists all installed Python packages (in the current env)
# - grep packagename searches for the packagename in the list of packages
# installes with pip/pip3
# Example usage:
pip list | grep numpy
numpy 1.20.3
numpydoc 1.1.0
$ python2 -m doesnt_exist |& grep -q 'No module named' && echo 'Nope' || echo 'Yup'
Nope
$ python2 -m math |& grep -q 'No module named' && echo 'Nope' || echo 'Yup'
Yup