Python google api

I am trying to learn the Google APIs and my experience with Python, so I am trying to use the google api python client to access some google services, but I am encountering an error creating a service object.

There is no problem importing the assembly module from apiclient.discovery:

>>> from apiclient.discovery import build >>> 

But when the time comes to create the service object (as it was done in the downloadable tutorial file), something will work, and I canโ€™t understand what is going wrong!

 >>> service = build('books','v1',developerKey=api_key) WARNING:root:No module named locked_file Traceback (most recent call last): File "build/bdist.macosx-10.10-intel/egg/googleapiclient/discovery_cache/__init__.py", line 38, in autodetect from . import file_cache File "build/bdist.macosx-10.10-intel/egg/googleapiclient/discovery_cache/file_cache.py", line 32, in <module> ImportError: No module named locked_file Traceback (most recent call last): File "<stdin>", line 1, in <module> File "build/bdist.macosx-10.10-intel/egg/oauth2client/util.py", line 140, in positional_wrapper File "build/bdist.macosx-10.10-intel/egg/googleapiclient/discovery.py", line 196, in build File "build/bdist.macosx-10.10-intel/egg/googleapiclient/discovery.py", line 242, in _retrieve_discovery_doc File "/Library/Python/2.7/site-packages/httplib2-0.9.2-py2.7.egg/httplib2/__init__.py", line 1609, in request (response, content) = self._request(conn, authority, uri, request_uri, method, body, headers, redirections, cachekey) File "/Library/Python/2.7/site-packages/httplib2-0.9.2-py2.7.egg/httplib2/__init__.py", line 1351, in _request (response, content) = self._conn_request(conn, request_uri, method, body, headers) File "/Library/Python/2.7/site-packages/httplib2-0.9.2-py2.7.egg/httplib2/__init__.py", line 1272, in _conn_request conn.connect() File "/Library/Python/2.7/site-packages/httplib2-0.9.2-py2.7.egg/httplib2/__init__.py", line 1036, in connect self.disable_ssl_certificate_validation, self.ca_certs) File "/Library/Python/2.7/site-packages/httplib2-0.9.2-py2.7.egg/httplib2/__init__.py", line 80, in _ssl_wrap_socket cert_reqs=cert_reqs, ca_certs=ca_certs) File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ssl.py", line 911, in wrap_socket ciphers=ciphers) File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ssl.py", line 520, in __init__ self._context.load_verify_locations(ca_certs) IOError: [Errno 13] Permission denied >>> 

Here's how I got to this point, if it would be useful: I started by installing the client library and all the other modules it depended on, as described here: Installing the Python Google API . I used the pip (and the necessary sudo) and everything went smoothly. I tried to fix my error by updating the modules with the pip -update argument, but this does not seem to be a problem, since they all say " The requirement has already been updated: {The name of the Module Document is here}", so I donโ€™t think the problem.

After that, I began to follow the tutorial. The tutorial provides an example API (which gives me problems) for interacting with Google books: Google Books example . I got google API developer key as described at the beginning of the tutorial, and I donโ€™t think the problem is that I donโ€™t even execute the service object.

I was looking for a mistake, but I did not see anyone with similar problems, so I hope people can help here!

Thanks,

MLP

+5
source share
2 answers

same here it seems that in oauth2client 2.0 there is no LockedFile

  >>> from oauth2client.locked_file import LockedFile Traceback (most recent call last): File "<stdin>", line 1, in <module> ImportError: No module named locked_file 

also i found an open problem on github. This is google-api-python-client error: https://github.com/google/google-api-python-client/issues/179

+5
source
 IOError: [Errno 13] Permission denied 

It looks like you have permission problems. Make chown 'username' 'python file'

Or chown -R 'username' 'directory name'

0
source

Source: https://habr.com/ru/post/1243290/


All Articles