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()
My data frame is called data, with columns including aggregate_demand and a few other variables. I'm creating a slider map in plotly express, and I want to make it so that anyone can run the script. It works just fine, but when I package it as an executable in pyinstaller using '''pyinstaller script.py --onefile''' and run it I get '''
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`