Reputation: 85
I'm trying to import the google.cloud bigquery library, but I keep getting an error. The error I got:
ImportError: cannot import name 'bigquery' from 'google.cloud' (unknown location)
pip install google-cloud-bigquery
pip install --upgrade google-cloud
pip install --upgrade google-cloud-bigquery
I also tried these methods but still the error persists
Upvotes: 1
Views: 3578
Reputation: 1412
If you are using virtual environment, activate it:
source <your-env>/bin/activate
Install the BigQuery client library:
pip install --upgrade google-cloud-bigquery
Import the library in your code:
from google.cloud import bigquery
If it still fails, verify whether you installed and activated the correct virtual environment.
If you are using serverless services such as Cloud Run, Functions, dataflow etc, make sure to add dependencies in requirements.txt
file with specific version:
google-cloud-bigquery==3.35
Upvotes: 1
Reputation: 53
If you are writing python code in Apigee cloud function, There should be one requirements.txt file, add the below line in it
google-cloud-bigquery
then import it in python file
from google.cloud import bigquery
Upvotes: 1