개발/Linux

[Linux] - Python Module 설치 확인 방법

Dortmoot 2022. 8. 11. 22:51

Module 여부 확인 방법


1. Module이 설치되어 있는 경우

$ python -c "import math"
$ echo $?
0                                # math module exists in system

2. Module이 설치되어 있는 경우

$ python -c "import numpy"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
ImportError: No module named numpy
$ echo $?
1                                # numpy module does not exist in system

 

Reference

https://askubuntu.com/questions/588390/how-do-i-check-whether-a-module-is-installed-in-python-and-install-it-if-needed