gasabr gasabr - 5 days ago 6
Python Question

Gmail API Quickstart AttributeError in Python

I'm trying to learn Gmail API with Python using Mac OSX.

I have a standard problem for this OS: the default installation of the "six" module is loaded before the one that pip installed. Google's solution(at the bottom of the page) or this answer don't work.

When I tried to perform Google's one, I haven't found file

~/.bashrc
on my computer, but I created that and tried to change PATH in both
~/.bash_profile
and
~/.bash_profile.pysave
. It still doesn't help.

What should I do to run the quickstart example on my OS X 10.11.3 with Python 2.7.10 or 3.4.4?

Traceback (most recent call last):
File "quickstart.py", line 76, in <module>
main()
File "quickstart.py", line 60, in main
credentials = get_credentials()
File "quickstart.py", line 48, in get_credentials
credentials = tools.run_flow(flow, store, flags)
File "/Library/Python/2.7/site-packages/oauth2client/util.py", line 135, in positional_wrapper
return wrapped(*args, **kwargs)
File "/Library/Python/2.7/site-packages/oauth2client/tools.py", line 199, in run_flow
authorize_url = flow.step1_get_authorize_url()
File "/Library/Python/2.7/site-packages/oauth2client/util.py", line 135, in positional_wrapper
return wrapped(*args, **kwargs)
File "/Library/Python/2.7/site-packages/oauth2client/client.py", line 2006, 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 490, in _update_query_params
parts = urllib.parse.urlparse(uri)
AttributeError: 'Module_six_moves_urllib_parse' object has no attribute 'urlparse'

Answer

Solution i have found: Reinstall Python 2.7, restart terminal.

Comments