Check if Python Package is installed

前端 未结 16 1054
刺人心
刺人心 2020-12-02 05:59

What\'s a good way to check if a package is installed while within a Python script? I know it\'s easy from the interpreter, but I need to do it within a script.

I g

16条回答
  •  春和景丽
    2020-12-02 06:34

    Go option #2. If ImportError is thrown, then the package is not installed (or not in sys.path).

提交回复
热议问题