ImportError: no module named 'urequests'

All ESP8266 boards running MicroPython.
Official boards are the Adafruit Huzzah and Feather boards.
Target audience: MicroPython users with an ESP8266 board.
Post Reply
nirtz89
Posts: 7
Joined: Sat May 01, 2021 7:42 pm

ImportError: no module named 'urequests'

Post by nirtz89 » Sat May 01, 2021 7:45 pm

Hi everyone,
I used my ESP8266 with MicroPython and everything worked great so far (so much better than Arduino :D)
I now want to start using API calls and all the tutorials suggest using `urequests`, however, when I try to import the library I get:

Code: Select all

ImportError: no module named 'urequests'

I tried flashing the latest build I could find:
esp8266-1m-20210430-unstable-v1.15-37-gd3eb6d68a.bin
I'm kinda stuck and have no idea what to do next.
Any help would be very much appreciated, thanks!

User avatar
Roberthh
Posts: 3667
Joined: Sat May 09, 2015 4:13 pm
Location: Rhineland, Europe

Re: ImportError: no module named 'urequests'

Post by Roberthh » Sat May 01, 2021 7:58 pm

The 1M firmware does not include urequests by default. You can add it manually to your file system by copying in this file:
into the directory lib:
https://github.com/micropython/micropyt ... equests.py

You may also need this one into a directory called lib/urllib.urequests:
https://github.com/micropython/micropyt ... request.py

nirtz89
Posts: 7
Joined: Sat May 01, 2021 7:42 pm

Re: ImportError: no module named 'urequests'

Post by nirtz89 » Sat May 01, 2021 9:20 pm

Roberthh wrote:
Sat May 01, 2021 7:58 pm
The 1M firmware does not include urequests by default. You can add it manually to your file system by copying in this file:
into the directory lib:
https://github.com/micropython/micropyt ... equests.py

You may also need this one into a directory called lib/urllib.urequests:
https://github.com/micropython/micropyt ... request.py
Thanks for the quick response :)
Sorry for the newbie question, I'm using uPyCraft, how do I add it to my ESP8266?

User avatar
Roberthh
Posts: 3667
Joined: Sat May 09, 2015 4:13 pm
Location: Rhineland, Europe

Re: ImportError: no module named 'urequests'

Post by Roberthh » Sun May 02, 2021 7:25 am

I do not us uPyCraft, so I do not know if it has an option to upload files to the board. Other tools to do so are e.g.
- rshell
- ampy
- pyboard.py
- thonny

Post Reply