Ahmet Buğra BUĞA
Ahmet Buğra BUĞA

Reputation: 85

Importing error "from google.cloud import bigquery"

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

Answers (2)

Rathish Kumar B
Rathish Kumar B

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

Aman shaw
Aman shaw

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

Related Questions