Check if Python Package is installed

前端 未结 16 1055
刺人心
刺人心 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

    A quick way is to use python command line tool. Simply type import You see an error if module is missing.

    $ python
    Python 2.7.6 (default, Jun 22 2015, 17:58:13) 
    >>> import sys
    >>> import jocker
    Traceback (most recent call last):
      File "", line 1, in 
    ImportError: No module named jocker
    $
    

提交回复
热议问题