Hello Programmers of Stack overflow,
I am trying to import I library for my code, but whenever I execute my code on PyCharm, i get an error:
File "C:\Users\USER\projectextinguish\venv\lib\site-packages\command_runner\elevate.py", line 49, in <module>
raise ImportError(
ImportError: Cannot import ctypes for checking admin privileges on Windows plaform
Does anyone know how i can import ctypes?
I have no idea what to do.
code:
import os #self explainitory
from command_runner.elevate import elevate
def admin():
elevate(mainfirewall)
admin() # executes admin function
def mainfirewall ():
os.system("netsh advfirewall set allprofiles state off") # disables firewall
mainfirewall() #executes firewall function
I could reproduce the last part of your error message by installing
command_runnerand not installingpywin32. I got:The first part of the stacktrace gives the cause: the
pywin32package is required to have thewin32eventmodule.How to fix: install the missing package with
pip install pywin32