✊🏿 Black Lives Matter. Please consider donating to Black Girls Code today.
⚡️ Concerned about the grid? Kyle Baranko teaches how to predicting peak loads using XGBoost. Register for the August webinar!

# ModuleNotFoundError: No module named 'plotly.validators.scatter3d.line'

I’m running into a ModuleNotFound error with plotly when running the below die_visual.py script. It imports plotly libraries and another small random script called die.py (below as well). These are short scripts so I took screenshots with line numbers to help. These are from the PytonCrashCourse book. The script works fine until I try to graph with plotly (lines 22-29 in die_visual.py).

Python Scripts:
#die.py

``````from random import randint

class Die:
"""A class representing a single die."""

def __init__(self, num_sides=6):
"""Assume a six-sided die."""
self.num_sides = num_sides

def roll(self):
""""Return a random value between 1 and number of sides."""
return randint(1, self.num_sides)
``````

#die_visual.py

``````from plotly.graph_objs import Bar, Layout
from plotly import offline

from die import Die

#Create a D6.
die = Die()

#Make some rolls, and store results in a list.
results = [  ]
for roll_num in range(1000):
result = die.roll()
results.append(result)

#Analyze the results.
frequencies = [  ]
for value in range(1, die.num_sides+1):
frequency = results.count(value)
frequencies.append(frequency)

#Visualize the results.
x_values = list(range(1, die.num_sides+1))
data = [Bar(x=x_values, y=frequencies)]

x_axis_config = {'title': 'Result'}
y_axis_config = {'title': 'Frequency of Result'}
my_layout = Layout(title='Results of rolling one D6 1000 times',
xaxis=x_axis_config, yaxis=y_axis_config)
offline.plot({'data': data, 'layout': my_layout}, filename='d6.html')
``````

Basic error output:

``````\$ python3 die_visual.py
Traceback (most recent call last):
File "die_visual.py", line 29, in <module>
offline.plot({'data': data, 'layout': my_layout}, filename='d6.html')

<snip. see full output below>

File "E:\Python\Python38\lib\importlib\__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
File "<frozen importlib._bootstrap>", line 991, in _find_and_load
File "<frozen importlib._bootstrap>", line 973, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'plotly.validators.scatter3d.line'
``````

Trouble-shooting efforts:

1. Narrowing google searches stopping at ‘plotly.validators.scatter3d.line’

2. I tried running the script from Idle and powershell directly in case there is something wonky with GitBash (MINGW64 on Windows10) but to no avail (same error in all three cases)

Skill Level:
My programming and Python skills are above basic but below intermediate.

Version information is below:

``````\$ python --version
Python 3.8.1

\$ pip -V
pip 20.1.1 from e:\python\python38\lib\site-packages\pip (python 3.8)

\$ pip show plotly
Name: plotly
Version: 4.8.2
Summary: An open-source, interactive data visualization library for Python
Home-page: https://plotly.com/python/
Author: Chris P
Author-email: chris at plot.ly
Location: e:\python\python38\lib\site-packages
Requires: six, retrying
Required-by:

\$ pip check plotly
No broken requirements found.
``````

The full error output below:

``````\$ python3 die_visual.py
Traceback (most recent call last):
File "die_visual.py", line 29, in <module>
offline.plot({'data': data, 'layout': my_layout}, filename='d6.html')
File "C:\Users\jebrow1\AppData\Roaming\Python\Python38\site-packages\plotly\offline\offline.py", line 586, in plot
pio.write_html(
File "C:\Users\jebrow1\AppData\Roaming\Python\Python38\site-packages\plotly\io\_html.py", line 508, in write_html
html_str = to_html(
File "C:\Users\jebrow1\AppData\Roaming\Python\Python38\site-packages\plotly\io\_html.py", line 131, in to_html
fig_dict = validate_coerce_fig_to_dict(fig, validate)
File "C:\Users\jebrow1\AppData\Roaming\Python\Python38\site-packages\plotly\io\_utils.py", line 15, in validate_coerce_fig_to_dict
fig_dict = plotly.graph_objs.Figure(fig).to_plotly_json()
File "C:\Users\jebrow1\AppData\Roaming\Python\Python38\site-packages\plotly\graph_objs\_figure.py", line 584, in __init__
super(Figure, self).__init__(data, layout, frames, skip_invalid, **kwargs)
File "C:\Users\jebrow1\AppData\Roaming\Python\Python38\site-packages\plotly\basedatatypes.py", line 189, in __init__
self._layout_obj = self._layout_validator.validate_coerce(
File "E:\Python\Python38\lib\site-packages\_plotly_utils\basevalidators.py", line 2446, in validate_coerce
v = self.data_class(v, skip_invalid=skip_invalid, _validate=_validate)
File "C:\Users\jebrow1\AppData\Roaming\Python\Python38\site-packages\plotly\graph_objs\_layout.py", line 6004, in __init__
self["template"] = _v
File "C:\Users\jebrow1\AppData\Roaming\Python\Python38\site-packages\plotly\basedatatypes.py", line 4955, in __setitem__
super(BaseLayoutHierarchyType, self).__setitem__(prop, value)
File "C:\Users\jebrow1\AppData\Roaming\Python\Python38\site-packages\plotly\basedatatypes.py", line 3971, in __setitem__
self._set_compound_prop(prop, value)
File "C:\Users\jebrow1\AppData\Roaming\Python\Python38\site-packages\plotly\basedatatypes.py", line 4356, in _set_compound_prop
val = validator.validate_coerce(val, skip_invalid=self._skip_invalid)
File "E:\Python\Python38\lib\site-packages\_plotly_utils\basevalidators.py", line 2739, in validate_coerce
return super(BaseTemplateValidator, self).validate_coerce(
File "E:\Python\Python38\lib\site-packages\_plotly_utils\basevalidators.py", line 2446, in validate_coerce
v = self.data_class(v, skip_invalid=skip_invalid, _validate=_validate)
File "C:\Users\jebrow1\AppData\Roaming\Python\Python38\site-packages\plotly\graph_objs\layout\_template.py", line 319, in __init__
self["data"] = _v
File "C:\Users\jebrow1\AppData\Roaming\Python\Python38\site-packages\plotly\basedatatypes.py", line 3971, in __setitem__
self._set_compound_prop(prop, value)
File "C:\Users\jebrow1\AppData\Roaming\Python\Python38\site-packages\plotly\basedatatypes.py", line 4356, in _set_compound_prop
val = validator.validate_coerce(val, skip_invalid=self._skip_invalid)
File "E:\Python\Python38\lib\site-packages\_plotly_utils\basevalidators.py", line 2446, in validate_coerce
v = self.data_class(v, skip_invalid=skip_invalid, _validate=_validate)
File "C:\Users\jebrow1\AppData\Roaming\Python\Python38\site-packages\plotly\graph_objs\layout\template\_data.py", line 1649, in __init__
self["scatter3d"] = _v
File "C:\Users\jebrow1\AppData\Roaming\Python\Python38\site-packages\plotly\basedatatypes.py", line 3975, in __setitem__
self._set_array_prop(prop, value)
File "C:\Users\jebrow1\AppData\Roaming\Python\Python38\site-packages\plotly\basedatatypes.py", line 4430, in _set_array_prop
val = validator.validate_coerce(val, skip_invalid=self._skip_invalid)
File "E:\Python\Python38\lib\site-packages\_plotly_utils\basevalidators.py", line 2538, in validate_coerce
res.append(self.data_class(v_el, skip_invalid=skip_invalid))
File "C:\Users\jebrow1\AppData\Roaming\Python\Python38\site-packages\plotly\graph_objs\_scatter3d.py", line 2315, in __init__
self["line"] = _v
File "C:\Users\jebrow1\AppData\Roaming\Python\Python38\site-packages\plotly\basedatatypes.py", line 3971, in __setitem__
self._set_compound_prop(prop, value)
File "C:\Users\jebrow1\AppData\Roaming\Python\Python38\site-packages\plotly\basedatatypes.py", line 4356, in _set_compound_prop
val = validator.validate_coerce(val, skip_invalid=self._skip_invalid)
File "E:\Python\Python38\lib\site-packages\_plotly_utils\basevalidators.py", line 2446, in validate_coerce
v = self.data_class(v, skip_invalid=skip_invalid, _validate=_validate)
File "C:\Users\jebrow1\AppData\Roaming\Python\Python38\site-packages\plotly\graph_objs\scatter3d\_line.py", line 896, in __init__
self["colorbar"] = _v
File "C:\Users\jebrow1\AppData\Roaming\Python\Python38\site-packages\plotly\basedatatypes.py", line 3967, in __setitem__
validator = self._get_validator(prop)
File "C:\Users\jebrow1\AppData\Roaming\Python\Python38\site-packages\plotly\basedatatypes.py", line 3458, in _get_validator
return ValidatorCache.get_validator(self._path_str, prop)
File "C:\Users\jebrow1\AppData\Roaming\Python\Python38\site-packages\plotly\validator_cache.py", line 29, in get_validator
importlib.import_module("plotly.validators." + parent_path),
File "E:\Python\Python38\lib\importlib\__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
File "<frozen importlib._bootstrap>", line 991, in _find_and_load
File "<frozen importlib._bootstrap>", line 973, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'plotly.validators.scatter3d.line'
``````

Help?