我在本地创建了一个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获取查询结果。
发布于 2021-08-16 21:07:29
我通过在我的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-16 20:20:11
要访问bigquery,您需要将该库添加到requirements.txt
文件中:
pip install google-cloud-bigquery
https://stackoverflow.com/questions/68806805
复制相似问题