I just put my hands on RP Pico W to try it out but I hit the issue with the very first wifi test. Tutorials say to do this:
import network
import socket
from time import sleep
from picozero import pico_temp_sensor, pico_led
import machine
so my pico lib folder looks like this when I imported all required packages:
However when try to run wifi test like this:
def connect():
#Connect to WLAN
wlan = network.WLAN(network.STA_IF)
wlan.active(True)
wlan.connect(ssid, password)
while wlan.isconnected() == False:
print('Waiting for connection...')
sleep(1)
ip = wlan.ifconfig()[0]
print(f'Connected on {ip}')
try:
connect()
except KeyboardInterrupt:
machine.reset()
it fails with following error:
>>> %Run -c $EDITOR_CONTENT
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/lib/network.py", line 8, in <module>
File "/lib/socket.py", line 42, in <module>
AttributeError: 'module' object has no attribute 'socket'
>>>
This is whole code, I skipped only ssid and password.
I cannot figure out what exactly is wrong here. I do not have any other files named the same as socket or so.
I took the example from RP foundation pages: https://projects.raspberrypi.org/en/projects/get-started-pico-w/2