import urequest

  • Hi all, i'm new and beginner but i've some experiance with raspberry,esp 8266,Tasmota,php,python,html.
    I bought recently a wipy 3,0 + pycom makr board. Pymakr software don't working on Win 10 then i use ATOM with pymakr package.
    My first trouble is the import of urequest module and http module.

    import urequests
    Traceback (most recent call last):
    File "<stdin>", line 1, in <module>
    ImportError: no module named 'urequests'

    I've last firmware installed but seem this module don't exist for my board. Why? Realy?

    And the second problem on this code :

    import machine,usocket
    from network import WLAN
    wlan = WLAN(mode=WLAN.STA)
    nets = wlan.scan()
    for net in nets:
    if net.ssid == 'CAMERE':
    print('Network found!')
    wlan.connect(net.ssid, auth=(net.sec, 'karate75'), timeout=5000)
    while not wlan.isconnected():
    machine.idle() # save power while waiting
    print('WLAN connection succeeded!')

    s = usocket.socket()
    s.connect(usocket.getaddrinfo('', 80)[0][-1])


    Network found!
    WLAN connection succeeded!
    Traceback (most recent call last):
    File "<stdin>", line 15, in <module>
    OSError: Network card not available

    Pycom MicroPython 1.20.2.rc6 [v1.11-01f49f7] on 2020-02-28; WiPy with ESP32
    Pybytes Version: 1.3.1
    Type "help()" for more information.

    Network card not available ???????????????????????????????????????????? Why? :(

    I'm stuck here. I neet to do https request to my apache server mounted on raspberry.
    I find a lot of examples on the net it use urequest with micropython but on my wipy board i can't import it!

    Please tell me why!
    I thanks all.

  • I had the same problem, and it was because the "urequest" module is not inside the LoPy, you've to upload it yourself with your project.

    Here you can find an "official" one to use!

  • Although I don't have an answer as to why system reports: "Network card not available"
    I have a concern about what seems to be common practice relating to waiting for an attach or connect to any network device.
    We should avoid using the statement

    while not wlan.isconnected():

    especially with the timeout option on the connect call.
    This will cause the system to hang if attach or connect can not be completed until manually reset or WatchDogTImer expiration.
    A better approach is to use a limiting loop for example:

    for ca in range (1,5):                  #  Experienced 3 once
        pycom.rgbled(0x504040)  #   bright pink means connecting to network
        if lte.isconnected() == True:
        pycom.rgbled(0x000000)  #   dark
        if ca == 5:
               machine.deepsleep(5) # cause a soft reset, retaining TimeOfDayclock, in 5 ms

    Of course the range and the timing of the sleep should be tuned based on experience.
    Blinking the LED is up to you and only worth anything if the system is somewhere that you can see it.

Log in to reply

Pycom on Twitter