python linux check for specific module code example
Example: bash check if python package is installed
$ 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