【问题标题】:ModuleNotFoundError: No module named 'google.cloud' When deploying Streamlit App to HerokuModuleNotFoundError:将 Streamlit 应用程序部署到 Heroku 时没有名为“google.cloud”的模块
【发布时间】:2021-10-18 17:45:13
【问题描述】:

我在本地创建了一个 python streamlit 应用程序,我的代码中有以下导入;

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

在我命令一个 requirements.txt 文件之后,它创建了以下文件;

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

在本地,它工作得很好。 我已成功将我的应用程序部署到heroku,但是当我运行该应用程序时,它说;

ModuleNotFoundError:没有名为“google.cloud”的模块

我在我的代码中使用 bigquery 查询并使用 service_account 获取查询结果。

【问题讨论】:

    标签: python heroku google-cloud-platform google-bigquery streamlit


    【解决方案1】:

    要访问 bigquery,您需要将库添加到您的 requirements.txt 文件中:

    pip install google-cloud-bigquery

    【讨论】:

    • 感谢您的建议 :)
    • 如果对您有帮助,请标记为正确答案。
    • 这对我有一点帮助,上面的解决了我的问题,但再次感谢。
    【解决方案2】:

    我通过在 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
    
    

    google-cloud-bigquery 本身是不够的,还取决于以下几点;

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

    【讨论】:

      猜你喜欢
      • 2021-08-30
      • 2021-05-01
      • 2021-11-18
      • 2021-09-08
      • 2021-08-04
      • 2021-07-18
      • 2020-04-08
      • 1970-01-01
      • 2014-02-20
      相关资源
      最近更新 更多