Search code examples
pythonherokugoogle-cloud-platformgoogle-bigquerystreamlit

ModuleNotFoundError: No module named 'google.cloud' When deploying Streamlit App to Heroku


I created a python streamlit app in my local , I have the following imports in my code ;

import requests
import geopandas as gpd
import numpy as np
import pandas as pd
import plotly.express as px
import plotly.graph_objs as go
import plotly
import matplotlib.pyplot as plt
import streamlit as st
from google.cloud import bigquery
from google.oauth2 import service_account

after that I commanded for a requirements.txt file , it created following ;

pandas==1.3.2
numpy==1.21.2
plotly==5.2.1
geopandas==0.9.0
requests==2.26.0
streamlit==0.86.0
matplotlib==3.4.3
protobuf==3.17.3

In local ,it works very well. I have deployed my app to heroku succesfully but when I run the app it says ;

ModuleNotFoundError: No module named 'google.cloud'

I am using bigquery queries in my code and taking query results with service_account.


Solution

  • I solved my problem by adding followings to my requirements.txt ;

    google.cloud < 0.34.0
    google.cloud.bigquery < 2.24.0
    google.cloud.core < 1.7.2
    google.auth < 1.34.0
    google.resumable.media < 1.3.3
    google.api.core < 1.31.1
    
    

    The google-cloud-bigquery is not enough itself also it depends on the followings;

    google-cloud-core  
    google-auth  
    google.resumable.media  
    google.api.core