Closed
Description
After upgrading from 3.7.1 to 3.8.1 (as installed via pip
/PyPI), simple plots break with UnboundLocalError: local variable 'config_dict' referenced before assignment
.
Minimum working example:
import plotly.graph_objs as go
go.Figure()
Expected behavior: a Figure
should be returned.
Figure({
'data': [], 'layout': {}
})
I'm running macOS and Python 3.7.0. Downgrading to plotly 3.7.1 is a workaround: sudo pip3 install plotly=3.7.1
.
Stack trace:
---------------------------------------------------------------------------
UnboundLocalError Traceback (most recent call last)
<ipython-input-1-0c49f1f32fec> in <module>()
1 import plotly.graph_objs as go
2
----> 3 go.Figure()
/usr/local/lib/python3.7/site-packages/plotly/graph_objs/_figure.py in __init__(self, data, layout, frames, skip_invalid)
501 is invalid AND skip_invalid is False
502 """
--> 503 super(Figure, self).__init__(data, layout, frames, skip_invalid)
504
505 def add_area(
/usr/local/lib/python3.7/site-packages/plotly/basedatatypes.py in __init__(self, data, layout_plotly, frames, skip_invalid)
196 # options are compatible with FigureWidget.
197 from plotly.offline.offline import _get_jconfig
--> 198 self._config = _get_jconfig(None)
199
200 # Frames
/usr/local/lib/python3.7/site-packages/plotly/offline/offline.py in _get_jconfig(config)
160 clean_config = {}
161
--> 162 plotly_platform_url = plotly.tools.get_config_plotly_server_url()
163
164 clean_config['plotlyServerURL'] = plotly_platform_url
/usr/local/lib/python3.7/site-packages/plotly/tools.py in get_config_plotly_server_url()
1286 data = {}
1287
-> 1288 return config_dict.get('plotly_domain', default_server_url)
1289
1290
UnboundLocalError: local variable 'config_dict' referenced before assignment
I observe the same behavior with more involved go.Figure()
calls, such as the following:
import plotly.graph_objs as go
import numpy as np
x = np.arange(0, 1, 0.03)
y = np.arange(0, 1, 0.03)
xx, yy = np.meshgrid(x, y)
f = lambda v: np.array(v[0])**2 + np.array(v[1])**2
@np.vectorize
def v_fun(x, y):
return f([x, y])
z = v_fun(xx, yy)
trace = [go.Surface(x=x, y=y, z=z, showscale=False)]
fig = go.Figure(data=trace,
layout=go.Layout(
scene={"xaxis": {'title': "", "tickfont": {"size": 10}, 'type': "linear"},
"yaxis": {"title": "", "tickfont": {"size": 10},
"tickangle": 1},
"zaxis": {'title': "Fitness", "tickfont": {"size": 10}},
"aspectratio": {'x': 2.0, 'y': 2.0, 'z': 1.0}
}
))
Metadata
Metadata
Assignees
Labels
No labels