0

As the title says.

So I've added the following to appengine_config.py with no luck:

# appengine_config.py
from google.appengine.ext import vendor

# Add any libraries install in the "lib" folder.
vendor.add('lib')

I did a print sys.path and verified the lib dir contains google/cloud/bigquery

I can import it if I run python myself:

 from google.cloud import bigquery
 print bigquery.__path__
 ['/usr/local/lib/python2.7/dist-packages/google/cloud/bigquery']

From a Google App Engine end points:

import google.cloud;print google.cloud.__path__
['/usr/local/lib/python2.7/dist-packages/google/cloud']

Big Query is at that system location. /usr/local/lib/python2.7/dist-packages/google/cloud/biqguery/ exists. However if I try the following from app engine end point:

 from google.cloud import bigquery

 ImportError: No module named google.cloud.bigquery

The file in question includes and that does not appear to help:

 from __future__ import absolute_import

Update

I setup a venv and install everything like this: pip install -t lib/ -r requirements.txt --upgrade. From there if I try import google; print google.__path__ I get:

 ['lib/google', '/usr/lib/google-cloud-sdk/platform/google_appengine/google']

I think the second path might be the cause.

I've reviewed the following with no success:

Halsafar
  • 2,540
  • 4
  • 29
  • 52
  • A possible workaround was posted [on Google Groups](https://groups.google.com/forum/#!msg/google-appengine/C5LjgIiJwJY/It6nZKLRCQAJ), is it of any help? Or have you now resolved this issue in some other way? – Yannick MG Sep 25 '17 at 20:28

1 Answers1

1

You need to install google-cloud-bigquery into you app's lib dir, that's where the development server is looking at, not on your system's libs. From Installing a third-party library:

  1. Create a directory to store your third-party libraries, such as lib/.

    mkdir lib
    
  2. Use pip (version 6 or later) with the -t <directory> flag to copy the libraries into the folder you created in the previous step. For example:

    pip install -t lib/ <library_name>
    
Dan Cornilescu
  • 39,470
  • 12
  • 57
  • 97
  • Well at first I created a venv and installing my requirements there. Did not help. I tried what you just suggested and same error. From the root of my project I executed your steps. Honestly I've already tried this but I felt maybe I should try again to be safe. Inside venv, outside venv. A hint might be that when deployed on google app engine I am getting the same error. I can check the sys.path and the first directory listed has the bigquery folder. – Halsafar Aug 06 '17 at 03:41
  • That `/usr/local/lib` path is useless on GAE - only the directories below your app (actually your app's service!) directory end up on GAE. – Dan Cornilescu Aug 06 '17 at 15:31
  • Yeah I've moved to using a venv, manually installing the libs in my projects lib dir. I made progress actually. bigquery is seen but now I am getting "no suitable implementation" when bigquery imports monotonic. I'll update my answer with details once I sort that out. Also running on GAE itself bigquery is still not found. – Halsafar Aug 06 '17 at 15:59
  • Also - don't try to import/check it from a regular python script or shell, but from a GAE app code. GAE apps work differently than standalone python apps - they work combined with supporting code in the GAE infra. – Dan Cornilescu Aug 06 '17 at 16:04