Gpy + Pysense - urequests AttributeError: 'module' object has no attribute 'get'
-
Hi
I am trying to make an HTTP get request for testing but have getting this message:
urequests.py library downloaded from https://github.com/micropython/micropython-lib/tree/master/urequestsPlease give me some help, i am started with Pycom...
Network found!
WLAN connection succeeded!RTC Set from NTP to UTC: (2018, 2, 28, 14, 23, 38, 97276, None)
Traceback (most recent call last):
File "main.py", line 11, in <module>
AttributeError: 'module' object has no attribute 'get'
MicroPython v1.8.6-849-055728a on 2018-02-13; GPy with ESP32
Type "help()" for more information.# boot.py import machine from network import WLAN wlan = WLAN(mode=WLAN.STA) nets = wlan.scan() for net in nets: if net.ssid == 'REMOVED': print('Network found!') wlan.connect(net.ssid, auth=(net.sec, 'REMOVED.'), timeout=5000) while not wlan.isconnected(): machine.idle() # save power while waiting print('WLAN connection succeeded!')
# main.py import urequests as requests import utime from machine import RTC rtc = machine.RTC() rtc.ntp_sync("pool.ntp.org") utime.sleep_ms(750) print('\nRTC Set from NTP to UTC:', rtc.now()) r = requests.get('http://api.xively.com/') print(r) print(r.content) print(r.text) print(r.content) print(r.json()) r.close()
-
@seb Everything work fine, after sync again!
Thank you very much
-
Ah there seems to have been an issue syncing the library because the output should be:
>>> import urequests as requests >>> print(dir(requests)) ['put', 'post', 'usocket', 'patch', 'request', '__file__', '__name__', 'delete', 'head', 'Response', 'get'] >>> print(type(requests)) <class 'module'>
Can you please run the following to clear your device and sync again:
import os os.mkfs('/flash')
-
thank you very much for your help!
-
In the REPL console can you please run the following:
import urequests as requests print(dir(requests)) print(type(requests))
-
@seb Yes i have the latest firmware, updated yesterday, Gpy, and Pysense
i have patch line 53, and the problem remains
-
- Are you on the latest firmware?
- Are you sure you have correctly downloaded the urequest.py file from the link you provided? When I attempted to run this code I could not replicate your error. I did however have to patch line 53 to be:
ai = usocket.getaddrinfo(host, port)