Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting AttributeError: 'module' object has no attribute 'DEFAULT_MAX_REDIRECTS' when running Google Sheets API quickstart

I'm following this guide https://developers.google.com/sheets/api/quickstart/python

Upon running the sample code they provided (The only thing I changed was the location of the api secret since we already had one set up and the APPLICATION_NAME) I get this error

AttributeError: 'module' object has no attribute 'DEFAULT_MAX_REDIRECTS'

Log before the error

  File "generate_report.py", line 2, in <module>
    import httplib2
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/httplib2/__init__.py", line 42, in <module>
    import calendar
  File "/Users/HarshaGoli/Git/PantherBot/scripts/calendar.py", line 1, in <module>
    from oauth2client.service_account import ServiceAccountCredentials
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/oauth2client/service_account.py", line 25, in <module>
    from oauth2client import client
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/oauth2client/client.py", line 39, in <module>
    from oauth2client import transport
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/oauth2client/transport.py", line 255, in <module>
    redirections=httplib2.DEFAULT_MAX_REDIRECTS,
like image 407
arshbot Avatar asked Mar 10 '26 08:03

arshbot


2 Answers

I got the same error and investigated on the problem.
In my case, it was caused by a file named ''calendar.py" in the same directory.
It's said you should avoid using general names that can be used for standard python library.

like image 103
Lunran Avatar answered Mar 11 '26 20:03

Lunran


It may be versioning problem. It could be python3 version of httplib2 which cause troubles, try to follow answer from this post

like image 30
Anton Avatar answered Mar 11 '26 20:03

Anton