← Go Back
            
Prior to Python 3.6, use
If you need to support both Python >= 3.6 and < 3.6, just use
            
            
        How to Check if a Module Is Installed
In Python 3.6 and above, catch deModuleNotFoundError exception:try:
    import win32api
except ModuleNotFoundError:
    print("pywin32 is not installed.")
else:
    print("pywin32 is installed!")
Prior to Python 3.6, use
ImportError:try:
    import win32api
except ImportError:
    print("pywin32 is not installed.")
else:
    print("pywin32 is installed!")
If you need to support both Python >= 3.6 and < 3.6, just use
ImportError.🐍 You might also find interesting: