Pyinstaller und die richtige Strategie
Verfasst: Dienstag 15. September 2020, 12:35
Hi,
ich tue mich grad ein wenig schwer, aus einer Django-App via PyInstaller eine eigenstaendige Anwendung zu erstellen.
Per se funktioniert es recht gut. Django laesst sich nach zwei drei Kleinigkeiten starten, aber sobald ich einen meiner Views aufrufe, der mir per Plotly einen Graphen erstellen soll, wird gemeckert, dass Imports fehlen.
Soweit so gut, man kann ja immerhin ueber die hidden Imports nachbessern .. also fehlenden Import geschnappt, mit eingefuegt, wieder kompiliert und gestartet, bum naechstes Problem.
Ich hab das jetzt schon ein zwei mal gemacht. Die Liste der hidden Imports ist inzwischen schon etwas gewachsen:
Das macht aber nur bedingt Spaß und ich frage mich, ob es einen besseren Weg gibt, herauszufinden welchen Weg der Analyzer einschlaegt, um den Prozess besser verstehen und damit lenken zu koennen?
Ich habe neben der obligatorischen manage.py auch extra meine views.py mit angegeben. Hier ist einer der Views, in dem ein Graph erstellt und als Bild-Stream ausgegeben wird:
Kann sein, dass Plotly hier das eigentliche Problem ist. Einen Hinweis gibt der BaseValidator:
Aber irgendwie habe ich trotzdem das Gefuehl, dass das eleganter gehen muss.
Hat jemand eine Idee?
ich tue mich grad ein wenig schwer, aus einer Django-App via PyInstaller eine eigenstaendige Anwendung zu erstellen.
Per se funktioniert es recht gut. Django laesst sich nach zwei drei Kleinigkeiten starten, aber sobald ich einen meiner Views aufrufe, der mir per Plotly einen Graphen erstellen soll, wird gemeckert, dass Imports fehlen.
Soweit so gut, man kann ja immerhin ueber die hidden Imports nachbessern .. also fehlenden Import geschnappt, mit eingefuegt, wieder kompiliert und gestartet, bum naechstes Problem.
Ich hab das jetzt schon ein zwei mal gemacht. Die Liste der hidden Imports ist inzwischen schon etwas gewachsen:
Code: Alles auswählen
'plotly.validators.layout.template',
'plotly.validators.heatmapgl.colorbar',
'plotly.validators.layout.colorscale',
'plotly.validators.layout.template.data',
'plotly.validators.scatter',
'plotly.validators.scatter.marker',
'plotly.validators.layout.margin',
'plotly.validators.layout.legend',
'plotly.validators.layout.xaxis',
'plotly.validators.layout.yaxis',
'plotly.validators.barpolar',
'plotly.validators.barpolar.marker',
'plotly.validators.barpolar.marker.line',
'plotly.validators.bar',
'plotly.validators.bar.error_x',
'plotly.validators.bar.error_y',
'plotly.validators.bar.marker',
'plotly.validators.bar.marker.line',
'plotly.validators.carpet',
'plotly.validators.carpet.aaxis',
'plotly.validators.carpet.baxis',
'plotly.validators.choropleth',
'plotly.validators.choropleth.colorbar',
'plotly.validators.contourcarpet',
'plotly.validators.contourcarpet.colorbar',
'plotly.validators.contour',
'plotly.validators.contour.colorbar',
'plotly.validators.heatmapgl',
'plotly.validators.heatmap.colorbar',
'plotly.validators.histogram2dcontour',
'plotly.validators.histogram2dcontour.colorbar',
'plotly.validators.histogram2d',
'plotly.validators.histogram2d.colorbar',
'plotly.validators.histogram',
'plotly.validators.histogram.marker',
'plotly.validators.histogram.marker.colorbar',
'plotly.validators.mesh3d',
'plotly.validators.mesh3d.colorbar',
'plotly.validators.parcoords',
'plotly.validators.parcoords.line',
'plotly.validators.parcoords.line.colorbar',
'plotly.validators.pie',
'plotly.validators.scatter3d',
'plotly.validators.scatter3d.line',
Ich habe neben der obligatorischen manage.py auch extra meine views.py mit angegeben. Hier ist einer der Views, in dem ein Graph erstellt und als Bild-Stream ausgegeben wird:
Code: Alles auswählen
def compare(request, year, indicator_id):
indicator = get_object_or_404(Indicator.data.all(), id=indicator_id)
import pandas
qs = DataPoint.data.filter(indicator=indicator, year=year).order_by('percentage')
qs = qs.annotate(officename=F('office__name')).annotate(
bubble_size=F("counter") * 1.5
)
df = pandas.DataFrame(list(qs.values()))
fig = px.scatter(
df,
x="percentage",
y="officename",
size="bubble_size",
size_max=60,
width=400,
height=700,
)
fig.update_layout(xaxis_title="", yaxis_title="")
fig.layout.annotations = [
dict(
x=point.percentage,
y=point.officename,
text=point.counter,
showarrow=False,
xanchor='center',
yanchor='middle',
)
for point in qs
]
fig.update_layout(margin=dict(l=0, r=10, t=10, b=10),)
image = fig.to_image(format="png")
return HttpResponse(image, content_type="image/png")
Code: Alles auswählen
def __init__(self, plotly_name, parent_name, role=None, **_):
"""
Construct a validator instance
Parameters
----------
plotly_name : str
Name of the property being validated
parent_name : str
Names of all of the ancestors of this property joined on '.'
characters. e.g.
plotly_name == 'range' and parent_name == 'layout.xaxis'
role : str
The role string for the property as specified in
plot-schema.json
"""
Hat jemand eine Idee?