from importlib.util import find_spec if find_spec("numpy") is not None: print("numpy is installed") else: print("numpy is not installed")