![](/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.