Python 使用谷歌restapi

Python 使用谷歌restapi,python,google-drive-api,Python,Google Drive Api,我正在尝试使用Google Drive API下载公开可用的文件,但是每当我尝试继续下载时,就会出现导入错误 作为参考,我已经成功地设置了OAuth2,这样我就有了一个客户机id、一个客户机机密和一个重定向url。然而,当我尝试设置它时,我得到一个错误,说该对象没有属性urllen >>> from apiclient.discovery import build >>> from oauth2client.client import OAuth2WebSer

我正在尝试使用Google Drive API下载公开可用的文件,但是每当我尝试继续下载时,就会出现导入错误

作为参考,我已经成功地设置了OAuth2,这样我就有了一个客户机id、一个客户机机密和一个重定向url。然而,当我尝试设置它时,我得到一个错误,说该对象没有属性urllen

>>> from apiclient.discovery import build
>>> from oauth2client.client import OAuth2WebServerFlow
>>> flow = OAuth2WebServerFlow(client_id='not_showing_client_id', client_secret='not_showing_secret_id', scope='https://www.googleapis.com/auth/drive', redirect_uri='https://www.example.com/oauth2callback')
>>> auth_uri = flow.step1_get_authorize_url()
>>> code = '4/E4h7XYQXXbVNMfOqA5QzF-7gGMagHSWm__KIH6GSSU4#'
>>> credentials = flow.step2_exchange(code)
然后我得到一个错误:

Traceback (most recent call last):
File "<stdin>", line 1, in <module>
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    
1980, in step2_exchange
body = urllib.parse.urlencode(post_data)
AttributeError: 'Module_six_moves_urllib_parse' object has no attribute   
'urlencode'
但是,我仍然不清楚驱动器实例,因此,如果有任何帮助,我将不胜感激


编辑2:好的,我找到了我整个问题的答案。驱动器实例只是我们使用API根据文件id搜索文件时产生的元数据,正如我在编辑中所说的,请尝试sudo pip安装,文件实例只是元数据字典。

我在尝试连接Google Analytics API时遇到了类似的问题。安装google api python客户端的1.3.2版也解决了我的问题。
sudo pip install -I google-api-python-client==1.3.2