Error importing Google Cloud Bigquery api module in python app

google cloud function bigquery python
google cloud sdk python
cannot import name 'collections_abc' from 'six.moves' (unknown location)
google-cloud-bigquery python
google cloud python
the google-cloud-bigquery distribution was not found and is required by the application
python bigquery insert
from google.cloud import bigquery not working

I am trying to import bigquery into my python app from google.cloud import bigqueryand run it locally with dev_appserver.py, but I receive an error:

File "/Volumes/Budhi/Users/anjas/Projects/google-cloud-sdk/platform/google_appengine/google/appengine/runtime/wsgi.py", line 240, in Handle
handler = _config_handle.add_wsgi_middleware(self._LoadHandler())
File "/Volumes/Budhi/Users/anjas/Projects/google-cloud-sdk/platform/google_appengine/google/appengine/runtime/wsgi.py", line 299, in _LoadHandler
handler, path, err = LoadObject(self._handler)
File "/Volumes/Budhi/Users/anjas/Projects/google-cloud-sdk/platform/google_appengine/google/appengine/runtime/wsgi.py", line 85, in LoadObject
obj = __import__(path[0])
File "/Volumes/Budhi/Users/anjas/Projects/wordworks/urlworker/main.py", line 9, in <module>
from google.cloud import bigquery
File "/Volumes/Budhi/Users/anjas/Projects/google-cloud-sdk/platform/google_appengine/google/appengine/tools/devappserver2/python/sandbox.py", line 999, in load_module
raise ImportError('No module named %s' % fullname)
ImportError: No module named google.cloud.bigquery

I have installed bigquery lib with pip:

pip install --upgrade google-cloud-bigquery

Also I've tried installing it as 3d party library into lib directory with no result.

Though it works when I try importing bigquery lib from python shell:

Python 2.7.10 (default, Jul 30 2016, 18:31:42) 
[GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.34)] on darwin
Type "help", "copyright", "credits" or "license" for more  information.
>>> from google.cloud import bigquery
>>> 

Update:

It seems that "google" module installed to project/lib/ folder is clashing with "google" module in google-cloud-sdk/platform/google_appengine.

When trying to do

from google.cloud import bigquery

python looks for the module inside google-cloud-sdk/platform/google_appengine/google not inside project/lib/google/cloud

Any ideas?

I experienced exactly the same error and fixed this by deleting google folder in appengine sdk or you can just try to copy that to your lib folder . This will fix the problem on local development environment but you need to revert this when deploying your service on production.

I could not find a workaround to keep both google-cloud-sdk/platform/google_appengine/google and project/lib/google/cloud. You need to delete one of them

google-cloud-bigquery · PyPI, I am trying to import bigquery into my python app from google.cloud import bigquery and run it locally with dev_appserver.py, but I receive an error: Viewed 6k times. 3. I am trying to import bigquery into my python app from google.cloud import bigquery and run it locally with dev_appserver.py, but I receive an error: File "/Volumes/Budhi/Users/anjas/Projects/google-cloud-sdk/platform/google_appengine/google/appengine/runtime/wsgi.py", line 240, in Handle handler = _config_handle.add_wsgi_middleware(self._LoadHandler()) File "/Volumes/Budhi/Users/anjas/Projects/google-cloud-sdk/platform/google_appengine/google/appengine/runtime/wsgi.py

Did you add the lib folder in the appengine_config.py?

from google.appengine.ext import vendor
vendor.add('lib')

BigQuery API Client Libraries, Google BigQuery API client library. pip install google-cloud-bigquery Google BigQuery solves this problem by enabling super-fast, SQL queries against Install this library in a virtualenv using pip. virtualenv is a tool to create isolated Python environments. from google.cloud import bigquery client = bigquery.​Client()  pip install --upgrade google-cloud-bigquery Also I've tried installing it as 3d party library into lib directory with no result. Though it works when I try importing bigquery lib from python shell:

I had the same problem. If you're running this on your local environment, you may want to try adding the lib folder location into your $PYTHONPATH environment variable or adding below code lines before you import the bigquery lib which inserting the lib folder location into the a list of strings that specifies the search path for modules.

import sys    
sys.path.insert(0, 'lib')

I believe this works because now python files don't need to be inside of a package.

Setting Up Error Reporting for Python, Information about interacting with BigQuery API in C#, Go, Java, Node.js, PHP, Python, and To run the client library, you must first set up authentication by creating a export GOOGLE_APPLICATION_CREDENTIALS="/home/user/​Downloads/ Writer, projectID string) error { // projectID := "my-project-id" ctx := context. Even without installing anything, the snippet import google.cloud.bigquery will fail. This seems to be specific to the Python 2 environment (It will just work in a Python 3 notebook). I have more details for this in #2071

I think you are experiencing something very close to what i am experiencing, though i am seeing it during tests.

I think it might be because of the path manipulation needed by google sdk: the libs shipped with the sdk are being seen before the ones you are putting in the libs folder.

Here's what happens to me, with some details:

Wrong dependency in Google Cloud SDK for google-auth?

Error running "from google.cloud import storage" command · Issue , Thank you for reporting an issue to google-cloud-python! google-cloud-​bigquery==0.26.0 Elastic Beanstalk creates its own virtual environments on application gensim==2.0.0 google-api-python-client==1.6.2 google-auth==1.1.​1 No module named 'google.protobuf' using --target on amazonlinux  I was able to find the following link explaining that you should run the following command pip install --upgrade google-cloud-bigquery to install the Python BigQuery client library. There's also an example at the bottom of the page on how to call the library.

Install google-cloud-python not working? · Issue #2366 · googleapis , Does anyone know if how to install google-cloud python client library? from google.cloud import storage complains that cloud module doesn't exi no module name error : google not found even after installing it from pip @dmvtmn google-cloud-bigquery names the distribution installed by pip: it  i have built an app engine application to load data into bigquery table using google app engine launcher but when I run it on local host or on the cloud i get the No module named cloud while using

BigQuery Import not working on local dev_appserver. (Import error , where lib is the folder where i have all python libraries. This successfully install the library lib/google/cloud/bigquery. But when i try to import it in dev console by  Data import service for scheduling and moving data into BigQuery. Cloud Data Transfer Tools and services for transferring your data to Google Cloud.

Python Client for Google BigQuery, On January 1, 2020 this library will no longer support Python 2 on the latest released version. Google BigQuery solves this problem by enabling super-fast, SQL queries against append-mostly tables, using the processing Enable the Google Cloud BigQuery API. from google.cloud import bigquery client = bigquery. from google.cloud import bigquery # Construct a BigQuery client object. client = bigquery.Client() query = """ SELECT name, SUM(number) as total_people FROM `bigquery-public-data.usa_names.usa_1910_2013` WHERE state = 'TX' GROUP BY name, state ORDER BY total_people DESC LIMIT 20 """ query_job = client.query(query) # Make an API request.

Comments
  • did you installed the library on your lib folder exists on project's root ?
  • sure, I've tried installing some other libs like Flask and there was no issue importing them
  • I am having this same issue. All my other installed vendor libs work fine. bigquery however I cannot import locally or remotely. I've followed every solution I can find with no success.
  • Yes I did. I've came across some other thing though, the package installed lib/google had no init.py inside, so it was not recognized as package. Adding init.py solves nothing. Seems like this SDK is meant to be installed globally. But I have installed it globally and yet no result.
  • vendor.add('lib') is basically a wrapper around sys.path.insert().