How to import google-api-python-client in web2py?

323 views
Skip to first unread message

Peter Weicher

unread,
Mar 20, 2017, 9:38:12 AM3/20/17
to web2py-users
Hello, 

I am trying to use web2py to build an application that requests data from various google APIs.

Using my local install of Python 3 or Python 2, I am able to import the necessary modules and query the api. 

I have tried the following, restarting the webserver between each action:

1) copying google-api-python-client modules into C:\web2py\web2py\site-packages
  • This does not work, I get <type 'exceptions.AttributeError'> 'module' object has no attribute 'DEFAULT_MAX_REDIRECTS'
  • package httplib2 definitely has a value called 'DEFAULT_MAX_REDIRECTS'
  • see Traceback #1
2) delete files and then cmd: python -m pip install --target= google-api-python-client
  • same result as first action
  • see Traceback #1
3) Copy or pip files to C:\web2py\web2py\applications\ping\modules

  • This does not work either, I get error: <type 'exceptions.ImportError'> cannot import name discovery
  • See Traceback #2

Has anyone successfully imported google-api-python-client into a web2py local instance?
Is there a setup step I am missing?

Full list of modules I am talking about is below, and the google instructions are here: https://developers.google.com/api-client-library/python/start/installation


Thank you!

Peter

___________________________________________________________________________________________________

Traceback #1
Traceback (most recent call last):
File "C:\web2py\web2py\gluon\restricted.py", line 227, in restricted
exec ccode in environment
File "C:/web2py/web2py/applications/ping/models/db.py", line 10, in <module>
from apiclient import discovery
File "C:\web2py\web2py\gluon\custom_import.py", line 74, in custom_importer
return NATIVE_IMPORTER(oname, globals, locals, fromlist, level)
File "C:\web2py\web2py\site-packages\apiclient\__init__.py", line 19, in <module>
from googleapiclient import discovery
File "C:\web2py\web2py\gluon\custom_import.py", line 74, in custom_importer
return NATIVE_IMPORTER(oname, globals, locals, fromlist, level)
File "C:\web2py\web2py\site-packages\googleapiclient\discovery.py", line 56, in <module>
from googleapiclient import _auth
File "C:\web2py\web2py\gluon\custom_import.py", line 74, in custom_importer
return NATIVE_IMPORTER(oname, globals, locals, fromlist, level)
File "C:\web2py\web2py\site-packages\googleapiclient\_auth.py", line 27, in <module>
import oauth2client.client
File "C:\web2py\web2py\gluon\custom_import.py", line 74, in custom_importer
return NATIVE_IMPORTER(oname, globals, locals, fromlist, level)
File "C:\web2py\web2py\site-packages\oauth2client\client.py", line 39, in <module>
from oauth2client import transport
File "C:\web2py\web2py\gluon\custom_import.py", line 74, in custom_importer
return NATIVE_IMPORTER(oname, globals, locals, fromlist, level)
File "C:\web2py\web2py\site-packages\oauth2client\transport.py", line 255, in <module>
redirections=httplib2.DEFAULT_MAX_REDIRECTS,
AttributeError: 'module' object has no attribute 'DEFAULT_MAX_REDIRECTS'

----------------------------------------
Traceback #2
Traceback (most recent call last):
File "C:\web2py\web2py\gluon\restricted.py", line 227, in restricted
exec ccode in environment
File "C:/web2py/web2py/applications/ping/models/db.py", line 10, in <module>
from apiclient import discovery
File "C:\web2py\web2py\gluon\custom_import.py", line 95, in custom_importer
return base_importer(pname, globals, locals, fromlist, level)
File "applications\ping\modules\apiclient\__init__.py", line 19, in <module>
from googleapiclient import discovery
ImportError: cannot import name discovery

List of Modules

03/14/2017  11:57 AM    <DIR>          apiclient
03/14/2017  11:57 AM    <DIR>          googleapiclient
03/14/2017  11:57 AM    <DIR>          google_api_python_client-1.6.2.dist-info
03/14/2017  11:57 AM    <DIR>          httplib2
03/14/2017  11:57 AM    <DIR>          httplib2-0.10.3-py2.7.egg-info
03/14/2017  11:57 AM    <DIR>          oauth2client
03/14/2017  11:57 AM    <DIR>          oauth2client-4.0.0.dist-info
03/14/2017  11:57 AM    <DIR>          pyasn1
03/14/2017  11:57 AM    <DIR>          pyasn1-0.2.3.dist-info
03/14/2017  11:57 AM    <DIR>          pyasn1_modules
03/14/2017  11:57 AM    <DIR>          pyasn1_modules-0.0.8.dist-info
03/14/2017  11:57 AM    <DIR>          rsa
03/14/2017  11:57 AM    <DIR>          rsa-3.4.2.dist-info
03/14/2017  11:57 AM    <DIR>          six-1.10.0.dist-info
03/14/2017  11:49 AM            30,098 six.py
03/14/2017  11:57 AM    <DIR>          tests
03/14/2017  11:57 AM    <DIR>          uritemplate
03/14/2017  11:57 AM    <DIR>          uritemplate-3.0.0.dist-info

Marlysson Silva

unread,
Mar 27, 2017, 9:15:38 AM3/27/17
to web2py-users
So you try install by pip?
Reply all
Reply to author
Forward
0 new messages