Python 获取属性错误:';模块';对象没有属性';默认的_MAX_重定向';运行GoogleSheetsAPI快速启动时
我遵循这个指南 在运行他们提供的示例代码时(我唯一更改的是api密码的位置,因为我们已经设置了一个api密码和应用程序名称),我得到了这个错误Python 获取属性错误:';模块';对象没有属性';默认的_MAX_重定向';运行GoogleSheetsAPI快速启动时,python,google-sheets-api,Python,Google Sheets Api,我遵循这个指南 在运行他们提供的示例代码时(我唯一更改的是api密码的位置,因为我们已经设置了一个api密码和应用程序名称),我得到了这个错误 AttributeError: 'module' object has no attribute 'DEFAULT_MAX_REDIRECTS' 记录错误之前的日志 File "generate_report.py", line 2, in <module> import httplib2 File "/Library/Fr
AttributeError: 'module' object has no attribute 'DEFAULT_MAX_REDIRECTS'
记录错误之前的日志
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,
文件“generate_report.py”,第2行,在
导入httplib2
文件“/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site packages/httplib2/_init__.py”,第42行,在
导入日历
文件“/Users/HarshaGoli/Git/PantherBot/scripts/calendar.py”,第1行,在
从oauth2client.service\u帐户导入ServiceAccountCredentials
文件“/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site packages/oauth2client/service_account.py”,第25行,在
从oauth2client导入客户端
文件“/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site packages/oauth2client/client.py”,第39行,在
从oauth2client导入传输
文件“/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site packages/oauth2client/transport.py”,第255行,在
重定向=httplib2.DEFAULT\u MAX\u重定向,
我也犯了同样的错误,并对这个问题进行了调查。在我的例子中,它是由同一目录中名为“calendar.py”的文件引起的。
据说您应该避免使用可用于标准python库的通用名称。这可能是版本控制问题。可能是
python3
版本的httplib2
造成了问题,请尝试按照下面的答案来回答