Reputation: 91
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.
Upvotes: 8
Views: 3559
Reputation: 724
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
Upvotes: 0
Reputation: 3766
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.
Upvotes: 1