how to check if library is installed python 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