尝试在 Python 中运行 Gmail API 快速入门时出现属性错误 [英] Attribute Error trying to run Gmail API quickstart in Python

查看:27
本文介绍了尝试在 Python 中运行 Gmail API 快速入门时出现属性错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这里看起来可能存在版本不匹配问题.我应该如何修复它?

It looks like there might be a version mismatch problem here. How should I go about fixing it?

我尝试用 pip 更新 6,但这没有任何作用.

I've trying updating six with pip, but that doesn't do anything.

这是我看到的错误:

Traceback (most recent call last):
  File "./quickstart.py", line 27, in <module>
    credentials = run(flow, STORAGE, http=http)
  File "/Library/Python/2.7/site-packages/oauth2client/util.py", line 137, in positional_wrapper
    return wrapped(*args, **kwargs)
  File "/Library/Python/2.7/site-packages/oauth2client/old_run.py", line 120, in run
    authorize_url = flow.step1_get_authorize_url()
  File "/Library/Python/2.7/site-packages/oauth2client/util.py", line 137, in positional_wrapper
    return wrapped(*args, **kwargs)
  File "/Library/Python/2.7/site-packages/oauth2client/client.py", line 1827, in step1_get_authorize_url
    return _update_query_params(self.auth_uri, query_params)
  File "/Library/Python/2.7/site-packages/oauth2client/client.py", line 435, in _update_query_params
    parts = urllib.parse.urlparse(uri)
AttributeError: 'Module_six_moves_urllib_parse' object has no attribute 'urlparse'

推荐答案

我遇到了一个非常相似的问题,尽管使用的是完全不同的 API(计算引擎).我最终将 google api 客户端回滚到以前的版本 - 1.3.2 - 而不是最新的 - 1.4.0.为此,我跑了:

I ran into a very similar problem, albeit using a completely different API (compute engine). I ended up rolling back the google api client to the previous version - 1.3.2 - as opposed to the latest - 1.4.0. To do this, I ran:

sudo pip install -I google-api-python-client==1.3.2

然后能够运行我的代码.

And was then able to run my code.

我不确定这是否是同样的问题,但它似乎对我有用,希望这会有所帮助.

I'm not sure if this is the same problem, but it seems to have done the trick for me, hope this helps.

这篇关于尝试在 Python 中运行 Gmail API 快速入门时出现属性错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆