[SOLVED] imports issue
Posted: Wed May 22, 2019 7:51 am
Hello again,
I'm trying to import a module to connect to my wifi. i'm using a module because i don't want the ssid or password to be tracked on github
But it don't work in my main.py. In repl it works fine, I import ConnectWifi in both main.py and in the repl prompt and :
You'll notice the first line is a print statement from these few lines of code :
I'm trying to check if the import failed or not, it seems to pass but then i can't call it. ConnectWifi.greetings fails and the whole file fails.
Am i doing something wrong?
I'm trying to import a module to connect to my wifi. i'm using a module because i don't want the ssid or password to be tracked on github
But it don't work in my main.py. In repl it works fine, I import ConnectWifi in both main.py and in the repl prompt and :
Code: Select all
connect to wifi
Traceback (most recent call last):
File "main.py", line 15, in <module>
NameError: name 'ConnectWiFi' isn't defined
MicroPython v1.10-331-ge38c68310-dirty on 2019-05-09; ESP32 module with ESP32
Type "help()" for more information.
>>> import ConnectWifi
>>> ConnectWifi.greetings()
Hellooooo !
>>>
Code: Select all
import ConnectWifi
try:
ConnectWifi
except NameError:
print("no ConnectWifi")
else:
print("connect to wifi")
ConnectWiFi.greetings()
Am i doing something wrong?