How to check if a module is installed in Python and, if not, install it within the code?

后端 未结 7 2038
失恋的感觉
失恋的感觉 2021-01-31 17:35

I would like to install the modules \'mutagen\' and \'gTTS\' for my code, but I want to have it so it will install the modules on every computer that doesn\'t have them, but it

7条回答
  •  轮回少年
    2021-01-31 17:49

    If you would like to preview if a specific package (or some) are installed or not maybe you can use the idle in python. Specifically :

    1. Open IDLE
    2. Browse to File > Open Module > Some Module
    3. IDLE will either display the module or will prompt an error message.

    Above is tested with python 3.9.0

提交回复
热议问题