awkman / pywifi

A cross-platform module for manipulating WiFi devices.
MIT License
453 stars 154 forks source link

How to fix "NameError: name 'iface' is not defined " #68

Open abundant-ray opened 3 years ago

abundant-ray commented 3 years ago

It comes up with this whenever i run this script

import pywifi from pywifi import PyWiFi from pywifi import const from pywifi import Profile

This is the part of the code that fails

profile.key = password # use generated password
    iface.remove_all_network_profiles() # remove all the profiles which are previously connected to device
    tmp_profile = iface.add_network_profile(profile) # add new profile 
    time.sleep(0.1) # if script not working change time to 1 !!!!!!
    iface.connect(tmp_profile) # trying to Connect
    time.sleep(0.35) # 1s

Error message

File "passcracker.py", line 63, in main
iface.remove_all_network_profiles() # remove all the profiles which are previously connected to device
NameError: name 'iface' is not defined