import os
try:
import wmi
except ImportError:
os.system("pip install wmi")
def main():
# globals()["wmi"] = importlib.import_module("wmi")
from wmi import WMI
print(WMI())
if __name__ == "__main__":
main()
I encountered some error like this “ModuleNotFoundError: No module named ‘pywintypes'”,but when I run it again, it works.
I wanna know how to do it when I first run it, it won’t raise “ModuleNotFoundError: No module named ‘pywintypes'”
New contributor
ziyu.chu is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.