Python Google Api验证Http模块错误

Python Google Api验证Http模块错误,python,google-api,google-calendar-api,google-api-python-client,Python,Google Api,Google Calendar Api,Google Api Python Client,我正在开发有史以来第一个使用谷歌Api制作日历的应用程序。我在以下网站上阅读了谷歌的例子: 我第一次运行下面的程序时,它是成功的。我允许我的应用程序访问我的Google帐户,应用程序在我的应用程序目录中创建了一个带有auth info的calendar.dat文件。在我重新命名文件后,代码在auth中停止工作。我已经完全删除了该文件,并从头开始重新创建了它,但错误仍然存在 我仍然可以得到谷歌认证页面,并且仍然可以确认访问,之后我会收到一条消息,说明认证流程已经完成 这是代码(我用我的应用程序详细

我正在开发有史以来第一个使用谷歌Api制作日历的应用程序。我在以下网站上阅读了谷歌的例子:

我第一次运行下面的程序时,它是成功的。我允许我的应用程序访问我的Google帐户,应用程序在我的应用程序目录中创建了一个带有auth info的calendar.dat文件。在我重新命名文件后,代码在auth中停止工作。我已经完全删除了该文件,并从头开始重新创建了它,但错误仍然存在

我仍然可以得到谷歌认证页面,并且仍然可以确认访问,之后我会收到一条消息,说明认证流程已经完成

这是代码(我用我的应用程序详细信息填写的标准谷歌示例):

这是输出:

Your browser has been opened to visit:

    https://accounts.google.com/o/oauth2/auth? (auth url shortened)

If your browser is on a different machine then exit and re-run this
application with the command-line parameter 

  --noauth_local_webserver

Traceback (most recent call last):
  File "C:\Users\Desktop\Google Drive\Code\Python\Rooster\calendar.py", line 2, in <module>
    import httplib2
  File "C:\Python27\lib\site-packages\httplib2-0.7.6-py2.7.egg\httplib2\__init__.py", line 42, in <module>
    import calendar
  File "C:\Users\Desktop\Google Drive\Code\Python\Rooster\calendar.py", line 33, in <module>
    credentials = run(FLOW, storage)
  File "C:\Python27\lib\site-packages\google_api_python_client-1.0-py2.7.egg\oauth2client\util.py", line 120, in positional_wrapper
    return wrapped(*args, **kwargs)
  File "C:\Python27\lib\site-packages\google_api_python_client-1.0-py2.7.egg\oauth2client\tools.py", line 169, in run
    credential = flow.step2_exchange(code, http=http)
  File "C:\Python27\lib\site-packages\google_api_python_client-1.0-py2.7.egg\oauth2client\util.py", line 120, in positional_wrapper
    return wrapped(*args, **kwargs)
  File "C:\Python27\lib\site-packages\google_api_python_client-1.0-py2.7.egg\oauth2client\client.py", line 1128, in step2_exchange
    http = httplib2.Http()
AttributeError: 'module' object has no attribute 'Http'
您的浏览器已打开以访问:
https://accounts.google.com/o/oauth2/auth? (认证url缩短)
如果您的浏览器位于其他计算机上,请退出并重新运行此操作
具有命令行参数的应用程序
--noauth_本地_网络服务器
回溯(最近一次呼叫最后一次):
文件“C:\Users\Desktop\Google Drive\Code\Python\Rooster\calendar.py”,第2行,在
导入httplib2
文件“C:\Python27\lib\site packages\httplib2-0.7.6-py2.7.egg\httplib2\\uuuuu init\uuuuu.py”,第42行,在
导入日历
文件“C:\Users\Desktop\Google Drive\Code\Python\Rooster\calendar.py”,第33行,在
凭据=运行(流、存储)
文件“C:\Python27\lib\site packages\google\u api\u python\u client-1.0-py2.7.egg\oauth2client\util.py”,第120行,位于位置包装器中
已包装退货(*args,**kwargs)
文件“C:\Python27\lib\site packages\google\u api\u python\u client-1.0-py2.7.egg\oauth2client\tools.py”,第169行,正在运行
凭证=flow.step2_交换(代码,http=http)
文件“C:\Python27\lib\site packages\google\u api\u python\u client-1.0-py2.7.egg\oauth2client\util.py”,第120行,位于位置包装器中
已包装退货(*args,**kwargs)
文件“C:\Python27\lib\site packages\google\u api\u python\u client-1.0-py2.7.egg\oauth2client\client.py”,第1128行,在步骤2中
http=httplib2.http()
AttributeError:“模块”对象没有属性“Http”

问题在于,在您的运行目录中有一个名为calendar.py的文件。当Google的httplib2想要导入一个标准日历模块时,它会得到一个本地模块。在local one中,它执行它来执行导入。但由于httplib2尚未完全导入,calendar.py代码无法正常工作。
只需将calendar.py重命名为类似于myCalendar.py的名称。

非常感谢,我已经尝试过了,因为我怀疑这是问题所在,但是它不起作用。我正在用Aptana3编码,并在程序中重命名了文件。然而,在阅读了您的评论并检查了目录之后,Aptana似乎也生成了编译过的python文件,因此目录中还有一个额外的calendar.py。我想这不是Aptana,而是python。默认情况下,Python解释器创建编译版本。
Your browser has been opened to visit:

    https://accounts.google.com/o/oauth2/auth? (auth url shortened)

If your browser is on a different machine then exit and re-run this
application with the command-line parameter 

  --noauth_local_webserver

Traceback (most recent call last):
  File "C:\Users\Desktop\Google Drive\Code\Python\Rooster\calendar.py", line 2, in <module>
    import httplib2
  File "C:\Python27\lib\site-packages\httplib2-0.7.6-py2.7.egg\httplib2\__init__.py", line 42, in <module>
    import calendar
  File "C:\Users\Desktop\Google Drive\Code\Python\Rooster\calendar.py", line 33, in <module>
    credentials = run(FLOW, storage)
  File "C:\Python27\lib\site-packages\google_api_python_client-1.0-py2.7.egg\oauth2client\util.py", line 120, in positional_wrapper
    return wrapped(*args, **kwargs)
  File "C:\Python27\lib\site-packages\google_api_python_client-1.0-py2.7.egg\oauth2client\tools.py", line 169, in run
    credential = flow.step2_exchange(code, http=http)
  File "C:\Python27\lib\site-packages\google_api_python_client-1.0-py2.7.egg\oauth2client\util.py", line 120, in positional_wrapper
    return wrapped(*args, **kwargs)
  File "C:\Python27\lib\site-packages\google_api_python_client-1.0-py2.7.egg\oauth2client\client.py", line 1128, in step2_exchange
    http = httplib2.Http()
AttributeError: 'module' object has no attribute 'Http'