Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

'Module object has no attribute 'get' Python error Requests?

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'

like image 304
mojians Avatar asked Sep 04 '12 07:09

mojians


People also ask

How do I fix Python module has no attribute?

To solve the Python "AttributeError: module has no attribute", make sure you haven't named your local modules with names of remote modules, e.g. datetime.py or requests.py and remove any circular dependencies in import statements.

Has no attribute error Python?

It's simply because there is no attribute with the name you called, for that Object. This means that you got the error when the "module" does not contain the method you are calling.


1 Answers

This is the typical symptom of an unrelated requests.py (or requests.pyc) file sitting in your current directory, or somewhere else on the PYTHONPATH. If this is the case, remove or rename it, as it's shadowing the module you really want to import.

like image 192
user4815162342 Avatar answered Sep 23 '22 01:09

user4815162342