Shinylive Pyodid kann kein glänzendes Paket für ein Quarto -Dashboard installierenPython

Python-Programme
Anonymous
 Shinylive Pyodid kann kein glänzendes Paket für ein Quarto -Dashboard installieren

Post by Anonymous »

Ich versuche, eine Shinylive -App in ein Quarto -Dashboard einzubetten. Die APP lässt den Benutzer eine kategoriale Variable in einer Seeborn -Barplot auswählen.

Code: Select all

Error starting app!

Traceback (most recent call last):
File "", line 362, in _start_app
ModuleNotFoundError: The module 'shiny' is included in the Pyodide distribution, but it is not installed.
You can install it by calling:
await micropip.install("shiny") in Python, or
await pyodide.loadPackage("shiny") in JavaScript
See https://pyodide.org/en/stable/usage/loading-packages.html for more details.
< /code>
derzeit in meinem [b]_quarto.yml
[/b]

Code: Select all

project:
type: website
output-dir: public

website:
title: "title"
navbar:
left:
- href: index.qmd
text: Home
- href: about.qmd
text: About

format: dashboard

filters:
- shinylive

jupyter: python3
< /code>
und mein [b]index.qmd
[/b]

Code: Select all

```{python py_load_deps}
#| echo: false

# data munging & viz
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.dates as mdates
import seaborn as sns
import plotly.express as px
```

## Row

Some explainer text.

## Row

```{shinylive-python}
#| standalone: true

#| title: Grouped Bar Plot - NOV 2023

## file: dat/filename.xlsx

from shiny import *
import pandas as pd
import numpy as np
import seaborn as sns
from pathlib import Path

# UI
app_ui = ui.page_fluid(
ui.input_select(
"select_items",
"select items:",
dat().item.unique().tolist(),
multiple = True
),
ui.output_plot("plot")
)

# server
def server(input, output, session):
@reactive.calc
def dat():
v_path = Path(__file__).parent.resolve() / "dat/filename.xlsx"
dict_types = {"item": str, "value": np.float64, "value2": np.float64}
df_summary = pd.read_excel(v_path, sheet_name="sheet_name", usecols="A:D", dtype=dict_types)
df_summary_grp = df_summary.melt(id_vars='item', value_vars=['value1', 'value2'])
df_summary_grp = df_summary_grp.reset_index()

return df_summary_grp

@reactive.calc
def items():
return dat().item.unique().tolist()

@output
@render.plot(alt="Grouped Bar of Items")
def plot():
g_ax_item_grp = sns.barplot(y='item', x='values', hue='variable', data=dat().loc[dat()[['item']].isin[input.select_item()]])
g_ax_item_grp.set_xlabel(None)
sns.move_legend(g_ax_item_grp, loc="lower center", bbox_to_anchor=(-.4,-.3), ncol=2, title=None, frameon=False)
return g_ax_item_grp

# app
app = App(app_ui, server)

```
Ich habe überprüft, ob alle Pakete installiert sind, und haben versucht, micropip.install ('Shiny') zum in der Fehlermeldung angegebenen Shinylive -Block hinzuzufügen, aber ohne Verfügbarkeit.

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post