try running tor service, add the following function to your code.
def connect_tor(port):
socks.set_default_proxy(socks.PROXY_TYPE_SOCKS5, '127.0.0.1', port, True)
socket.socket = socks.socksocket
def main():
connect_tor()
driver = webdriver.Firefox()