![](/img/trans.png)
[英]ModuleNotFoundError when trying to use BigQuery from google.cloud
[英]ModuleNotFoundError: No module named 'google.cloud' When deploying Streamlit App to Heroku
我在本地创建了一个 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 获取查询结果。
要访问 bigquery,您需要将该库添加到您的requirements.txt
文件中:
pip install google-cloud-bigquery
我通过在 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
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.