8

I am trying to get Google's OAuth to work via the API client for Python.

https://developers.google.com/api-client-library/python/start/installation

I have used easy_setup to install it, and I have the apiclient packages in the same directory as my Python client. However, when I run my client, I get

from apiclient.discovery import build

from apiclient.errors import HttpError
ImportError: No module named errors

It looks like it can't find the errors.py class in the apiclient directory, but it is clearly there.

I have the packages included in my client:

from apiclient.discovery import build
from apiclient.http import MediaFileUpload
import httplib2
import mimetypes
from oauth2client.client import OAuth2WebServerFlow
from oauth2client.file import Storage as FileStorage
import oauth2client.tools

Is there a way around this?

Thanks.

1
  • 1
    can you do "from apiclient import errors" and wherever you have to use HttpError, use errors.HttpError, does it work like that? Else, it it very weird if you have it there but it's not importing - there must be something trivial you are missing. Check similar question and answers here - stackoverflow.com/questions/18267749/… Commented May 21, 2015 at 11:50

2 Answers 2

1

This sounds like a path problem.

From the command line in your OS, start the python binary:

user@/usr/bin python

You should see something like this:

Python 2.7.6 (default, Sep 9 2014, 15:04:36)

[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.39)] on darwin

Type "help", "copyright", "credits" or "license" for more information.

Next import sys, then print sys.path:

import sys

sys.path

sys.path will show all the locations python is currently aware of to look for libraries. Confirm that the api client exists in one of those paths, and that the permissions on that path are correct.

Sharing a screenshot of the output from the above steps will help further diagnose your problem.

Sign up to request clarification or add additional context in comments.

Comments

0

This is a super old question but I just figured out how to get the HttpError class so I thought I'd include how I did it.

from apiclient import discovery, http

def execute_query(api_query):
    try:
        results = api_query.execute()
    except http.HttpError:
        return None

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.