繁体   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