【发布时间】:2022-08-19 05:01:18
【问题描述】:
我有一个anaconda panel 应用程序,它在本地环境中完美运行, 但是当尝试使用 Google App Engine 部署它时,它给了我错误。
这是实际的source location 我将其修改为以下
应用程序.yaml
runtime: python
env: flex
entrypoint: panel serve app.py --address 0.0.0.0 --port 8080 --allow-websocket-origin=\"*\"
runtime_config:
python_version: 3.7
manual_scaling:
instances: 1
resources:
cpu: 1
memory_gb: 0.5
disk_size_gb: 10
应用程序.py
import hvplot.pandas
import pandas as pd
import numpy as np
import panel as pn
pn.extension(\'tabulator\')
# cache data to improve dashboard performance
if \'data\' not in pn.state.cache.keys():
df = pd.read_csv(
\'https://raw.githubusercontent.com/owid/co2-data/master/owid-co2-data.csv\')
pn.state.cache[\'data\'] = df.copy()
else:
df = pn.state.cache[\'data\']
# Fill NAs with 0s and create GDP per capita column
df = df.fillna(0)
df[\'gdp_per_capita\'] = np.where(
df[\'population\'] != 0, df[\'gdp\'] / df[\'population\'], 0)
# Make DataFrame Pipeline Interactive
idf = df.interactive()
# Define Panel widgets
year_slider = pn.widgets.IntSlider(
name=\'Year slider\', start=1750, end=2020, step=5, value=1850)
year_slider
# Radio buttons for CO2 measures
yaxis_co2 = pn.widgets.RadioButtonGroup(
name=\'Y axis\',
options=[\'co2\', \'co2_per_capita\', ],
button_type=\'success\'
)
continents = [\'World\', \'Asia\', \'Oceania\', \'Europe\',
\'Africa\', \'North America\', \'South America\', \'Antarctica\']
co2_pipeline = (
idf[
(idf.year <= year_slider) &
(idf.country.isin(continents))
]
.groupby([\'country\', \'year\'])[yaxis_co2].mean()
.to_frame()
.reset_index()
.sort_values(by=\'year\')
.reset_index(drop=True)
)
co2_plot = co2_pipeline.hvplot(
x=\'year\', by=\'country\', y=yaxis_co2, line_width=2, title=\"CO2 emission by continent\")
co2_table = co2_pipeline.pipe(
pn.widgets.Tabulator, pagination=\'remote\', page_size=10, sizing_mode=\'stretch_width\')
co2_vs_gdp_scatterplot_pipeline = (
idf[
(idf.year == year_slider) &
(~ (idf.country.isin(continents)))
]
.groupby([\'country\', \'year\', \'gdp_per_capita\'])[\'co2\'].mean()
.to_frame()
.reset_index()
.sort_values(by=\'year\')
.reset_index(drop=True)
)
co2_vs_gdp_scatterplot = co2_vs_gdp_scatterplot_pipeline.hvplot(x=\'gdp_per_capita\',
y=\'co2\',
by=\'country\',
size=80, kind=\"scatter\",
alpha=0.7,
legend=False,
height=500,
width=500)
yaxis_co2_source = pn.widgets.RadioButtonGroup(
name=\'Y axis\',
options=[\'coal_co2\', \'oil_co2\', \'gas_co2\'],
button_type=\'success\'
)
continents_excl_world = [\'Asia\', \'Oceania\', \'Europe\',
\'Africa\', \'North America\', \'South America\', \'Antarctica\']
co2_source_bar_pipeline = (
idf[
(idf.year == year_slider) &
(idf.country.isin(continents_excl_world))
]
.groupby([\'year\', \'country\'])[yaxis_co2_source].sum()
.to_frame()
.reset_index()
.sort_values(by=\'year\')
.reset_index(drop=True)
)
co2_source_bar_plot = co2_source_bar_pipeline.hvplot(kind=\'bar\',
x=\'country\',
y=yaxis_co2_source,
title=\'CO2 source by continent\')
# Layout using Template
template = pn.template.FastListTemplate(
title=\'World CO2 emission dashboard\',
sidebar=[pn.pane.Markdown(\"# CO2 Emissions and Climate Change\"),
pn.pane.Markdown(\"#### Carbon dioxide emissions are the primary driver of global climate change. It’s widely recognised that to avoid the worst impacts of climate change, the world needs to urgently reduce emissions. But, how this responsibility is shared between regions, countries, and individuals has been an endless point of contention in international discussions.\"),
pn.pane.PNG(\'climate_day.png\', sizing_mode=\'scale_both\'),
pn.pane.Markdown(\"## Settings\"),
year_slider],
main=[pn.Row(pn.Column(yaxis_co2,
co2_plot.panel(width=700), margin=(0, 25)),
co2_table.panel(width=500)),
pn.Row(pn.Column(co2_vs_gdp_scatterplot.panel(width=600), margin=(0, 25)),
pn.Column(yaxis_co2_source, co2_source_bar_plot.panel(width=600)))],
accent_base_color=\"#88d8b0\",
header_background=\"#88d8b0\",
)
# template.show()
template.servable()
一旦我运行gcloud app deploy,就会出现这个错误:
然后我降级了要求.txt
panel==0.12.0
bokeh==2.3.3
hvplot==0.7.2
aiohttp==3.8.1
aiosignal==1.2.0
async-timeout==4.0.2
attrs==21.4.0
backports.entry-points-selectable==1.1.1
base58==2.1.1
bitarray==1.2.2
cached-property==1.5.2
certifi==2021.10.8
charset-normalizer==2.0.10
click==8.0.3
colorama==0.4.4
commonmark==0.9.1
cytoolz==0.11.2
distlib==0.3.4
eth-abi==2.1.1
eth-account==0.5.7
eth-hash==0.3.2
eth-keyfile==0.5.1
eth-keys==0.3.4
eth-rlp==0.2.1
eth-typing==2.3.0
eth-utils==1.10.0
filelock==3.4.0
frozenlist==1.2.0
haralyzer==2.0.0
hexbytes==0.2.2
idna==3.3
ipfshttpclient==0.8.0a2
jsonschema==3.2.0
lru-dict==1.1.7
multiaddr==0.0.9
multidict==5.2.0
netaddr==0.8.0
numpy==1.21.6
pandas==1.3.5
parsimonious==0.8.1
pipenv==2021.11.23
pipenv-poetry-migrate==0.2.0
platformdirs==2.4.0
polygonscan-python==1.0.2
protobuf==3.19.4
pycryptodome==3.13.0
Pygments==2.11.2
pyrsistent==0.18.1
python-dateutil==2.8.2
python-dotenv==0.20.0
pytz==2022.1
requests==2.27.1
rich==9.13.0
rlp==2.0.1
six==1.16.0
tomlkit==0.10.1
toolz==0.11.2
typing-extensions==3.10.0.2
uniswap-python==0.5.5
urllib3==1.26.8
varint==1.0.2
virtualenv==20.10.0
virtualenv-clone==0.5.7
web3==5.26.0
websockets==9.1
yarl==1.7.2
然后以不可用而告终多边形扫描-python==1.0.2
有没有办法把这些包上传到谷歌云,不用像这样下载,如何解决?
-
请不要在问题中包含屏幕截图。它要求其他人手动复制本来应该复制粘贴的内容(例如
requirements.txt)。屏幕截图也可能不会超过问题。请添加原始的requirements.txt文件并包含命令(最好在本地 virtualenv 中),您可以在其中构建解决方案并满足要求。 Cloud Build 似乎无法正确协调软件包版本,并且此问题也应在本地重现(因为环境应相似|相同)。 -
您使用的是 App Engine 标准还是灵活?
-
@its 应用引擎,让我为此添加文件
标签: python google-app-engine anaconda panel