簡體   English   中英

運行良好的 Plotly express map 不能作為 Pyinstaller exe 工作

[英]Plotly express map that runs fine doesn't work as Pyinstaller exe

import os
import warnings
import setuptools
warnings.simplefilter(action='ignore', category = FutureWarning)

import packaging
import packaging.version
import packaging.specifiers
import packaging.requirements
import pandas as pd     #importing required packages and probably some unrequired packages
import plotly
import plotly.express as px 
import plotly.offline as offline

from plotly.graph_objs import *
import plotly.graph_objs as go
from plotly.offline import download_plotlyjs, init_notebook_mode, plot, iplot


from urllib.request import urlopen
import json

import numpy as np


with urlopen('https://raw.githubusercontent.com/plotly/datasets/master/geojson-counties-fips.json') as response:
    counties = json.load(response)     #pull shapefile of counties from the web


fig = px.choropleth(data, geojson = counties, locations='FIPS',          #the actual mapping part  
                    color='normalized_dollar_per_MHz_pop',    #change_in_demand, or 'normalized_dollar_per_MHz_pop', 'aggregate_demand'
                    title = "Auction rounds " + str(start_round) + ":" + str(number_of_rounds),
                    animation_frame = "round",
                    scope = 'usa',
                    range_color = [0.02, 0.3] #color continuous midpoint = 0 sub, range_color = [0.02, 0.18] or [0,40]
                    ) #px.colors.diverging.PiYG

   
fig.layout.update(
   updatemenus = [
      go.layout.Updatemenu(
         type = "buttons", direction = "right", active = 0, x = 0., y = 0,
         buttons=[dict(label="Play", method="animate", args=[None]),]
      )
   ]
)

fig.show()

我的數據框稱為數據,列包括 aggregate_demand 和一些其他變量。 我正在 plotly 中創建一個 slider map 快遞,我想讓它讓任何人都可以運行腳本。 它工作得很好,但是當我 package 使用 '''pyinstaller script.py --onefile''' 作為 pyinstaller 中的可執行文件並運行它時,我得到 '''

range_color = [0.02, 0.3] #color continuous midpoint = 0 sub, range_color = [0.02, 0.18] or [0,40]
  File "plotly/express/_chart_types.py", line 906, in choropleth
  File "plotly/express/_core.py", line 1793, in make_figure
  File "plotly/express/_core.py", line 885, in apply_default_cascade
  File "plotly/graph_objs/layout/_template.py", line 306, in __init__
ValueError: The first argument to the plotly.graph_objs.layout.Template 
constructor must be a dict or 
an instance of :class:`plotly.graph_objs.layout.Template`

我有完全相同的問題,但使用px.timeline

解決該問題的方法是將plotly添加到 PyInstaller 規范文件中的datas中。 更多關於這里的信息: https://stackoverflow.com/a/61119844/6286652

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM