Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"ImportError: cannot import name util" Error on Google Drive SDK Quickstart Example

I'm getting the following error message when attempting the Google Drive SDK Quickstart Example (https://developers.google.com/drive/quickstart).

Traceback (most recent call last):
  File "quickstart.py", line 6, in <module>
    from apiclient.discovery import build
  File "build/bdist.macosx-10.6-intel/egg/apiclient/discovery.py", line 45, in <module>
  File "build/bdist.macosx-10.6-intel/egg/apiclient/errors.py", line 26, in <module>
ImportError: cannot import name util

As explained in the tutorial, first on my Mac terminal I:

easy_install --upgrade google-api-python-client

I'm using a Mac OS 10.7.4 python 2.7.2

like image 977
Damon Avatar asked Sep 24 '12 23:09

Damon


1 Answers

I recommend using pip instead of easy_install. According to this answer to a similar question, it's likely that the Client Library and oauth2client libraries are incompatible. Best to upgrade both with pip install -U google-api-python-client (or pip3 for Python 3).

After you get the quickstart working, if you want to see slightly longer, more "real-world" examples of using the Drive API, here are some videos and blog posts I made for you:

  • Listing your files in Google Drive and code deep dive post
  • Google Drive: Uploading & Downloading Files plus "Poor man's plain text to PDF converter" code deep dive post (*)
  • Exporting a Google Sheet as CSV blog post only

(*) - TL;DR: upload plain text file to Drive, import/convert to Google Docs format, then export that Doc as PDF. Post above uses Drive API v2; this follow-up post describes migrating it to Drive API v3, and here's a developer video combining both "poor man's converter" posts.

like image 52
wescpy Avatar answered Sep 24 '22 23:09

wescpy