Closed andrefarrugia closed 3 years ago
Solved:
when building cx_freeze executable include plotly as part of the build options
from cx_Freeze import setup, Executable
build_exe_options = {"packages": ["os","tkinter","plotly","pandas","chart_studio"], "excludes": []}
base = None
setup( name = "Trial", version = "0.1", description = "My GUI application!", options = {"build_exe": build_exe_options}, executables = [Executable("trial.py", base=base)])
I have an issue when building my code using both pyInstaller(4.0) and cx_Freeze(6.3) errors below using cx_freeze, the plots work find when running the code on IDLE Python 3.8.6. I'm using plotly 4.12.0.
I have these issue when plotting a Gantt chart:
Traceback (most recent call last): File "C:\Users\andre.farrugia\AppData\Local\Programs\Python\Python38\lib\tkinter__init.py", line 1883, in call return self.func(*args) File "trial.py", line 175, in example2 File "C:\Users\andre.farrugia\AppData\Local\Programs\Python\Python38\lib\site-packages\plotly\figure_factory_gantt.py", line 997, in create_gantt fig = gantt_colorscale( File "C:\Users\andre.farrugia\AppData\Local\Programs\Python\Python38\lib\site-packages\plotly\figure_factory_gantt.py", line 595, in gantt_colorscale fig = go.Figure(data=data, layout=layout) File "C:\Users\andre.farrugia\AppData\Local\Programs\Python\Python38\lib\site-packages\plotly\graph_objs_figure.py", line 588, in init super(Figure, self).init(data, layout, frames, skip_invalid, **kwargs) File "C:\Users\andre.farrugia\AppData\Local\Programs\Python\Python38\lib\site-packages\plotly\basedatatypes.py", line 280, in init data = self._data_validator.validate_coerce( File "C:\Users\andre.farrugia\AppData\Local\Programs\Python\Python38\lib\site-packages_plotly_utils\basevalidators.py", line 2661, in validate_coerce trace = self.get_trace_class(trace_type)( File "C:\Users\andre.farrugia\AppData\Local\Programs\Python\Python38\lib\site-packages\plotly\graph_objs_scatter.py", line 2950, in init__ self["fill"] = _v File "C:\Users\andre.farrugia\AppData\Local\Programs\Python\Python38\lib\site-packages\plotly\basedatatypes.py", line 4522, in setitem validator = self._get_validator(prop) File "C:\Users\andre.farrugia\AppData\Local\Programs\Python\Python38\lib\site-packages\plotly\basedatatypes.py", line 4013, in _get_validator return ValidatorCache.get_validator(self._path_str, prop) File "C:\Users\andre.farrugia\AppData\Local\Programs\Python\Python38\lib\site-packages\plotly\validator_cache.py", line 28, in get_validator validator = getattr( AttributeError: module 'plotly.validators.scatter' has no attribute 'FillValidator'
and this issue when plotting a bar chart:
Exception in Tkinter callback Traceback (most recent call last): File "C:\Users\andre.farrugia\AppData\Local\Programs\Python\Python38\lib\tkinter__init.py", line 1883, in call return self.func(*args) File "trial.py", line 212, in example3 File "C:\Users\andre.farrugia\AppData\Local\Programs\Python\Python38\lib\site-packages\plotly\graph_objs_bar.py", line 2969, in init__ self["name"] = _v File "C:\Users\andre.farrugia\AppData\Local\Programs\Python\Python38\lib\site-packages\plotly\basedatatypes.py", line 4522, in setitem validator = self._get_validator(prop) File "C:\Users\andre.farrugia\AppData\Local\Programs\Python\Python38\lib\site-packages\plotly\basedatatypes.py", line 4013, in _get_validator return ValidatorCache.get_validator(self._path_str, prop) File "C:\Users\andre.farrugia\AppData\Local\Programs\Python\Python38\lib\site-packages\plotly\validator_cache.py", line 28, in get_validator validator = getattr( AttributeError: module 'plotly.validators.bar' has no attribute 'NameValidator'
The below is the code I'm using to plot the charts:
import plotly.figure_factory as ff import pandas as pd import plotly.graph_objects as go import chart_studio.plotly as py
def example2():
def example3():
fig = go.Figure() fig.add_trace(go.Bar( x=week, y=chambers, name='Primary Product', marker_color='indianred' ))
Here we modify the tickangle of the xaxis, resulting in rotated labels.