wendlers / ediplug-py

Simple Python class to access a "EDIMAX Smart Plug Switch SP-1101W"
MIT License
32 stars 19 forks source link

NameError: global name 'requests' is not defined #9

Closed EasyNT closed 6 years ago

EasyNT commented 7 years ago

I got this error, tested it on smartos (Solaris) and macOS 10.13:

Traceback (most recent call last): File "smartplug.py", line 658, in p = SmartPlug(options.host, (options.login, options.password)) File "smartplug.py", line 146, in init res = requests.head(self.url) NameError: global name 'requests' is not defined

requests is installed:

pip list

... ... requests (2.18.4)

Too tired to find the problem :)...

EasyNT commented 7 years ago

Got it, the problem lies in line 146:

146 res = requests.head(self.url)

should be:

146 res = req.head(self.url)

as you did:

26 import requests as req