I just installed the Requests module by using easy_install
and I tried to run the demo code of this tutorial,
import requests
payload = {'username': 'xxxx', 'password': 'xxxxx'}
r = requests.get('https://github.com/timeline.json')
but I get this error:
AttributeError:
'module' object has no attribute 'get'
You are importing all names from the
requestsmodule into your local namespace, which means you do not need to prefix them anymore with the module name:If you were to import the module with an
import requestsstatement instead, you added the module itself to your namespace and you do have to use the full name:Note that the above examples is what I got from my tests in the interpreter. If you get different results, you are importing the wrong module; check if you have an extra
requests.pyfile in your python package:You can also test for the name listing provided by the
requestsmodule: