You need a Mapbox access token to use the Mapbox widget. First, sign up for a free Mapbox account. Then, you can create a token by following the instructions here. Set Mapbox_TOKEN
as an environment variable to use the Mapbox widget. Alternatively, uncomment the following code block and replace YOUR-API-TOKEN
with your Mapbox access token.
--------------------------------------------------------------------------- KeyError Traceback (most recent call last) File /opt/conda/lib/python3.10/site-packages/traitlets/traitlets.py:656, in TraitType.get(self, obj, cls) 655 try: --> 656 value = obj._trait_values[self.name] 657 except KeyError: 658 # Check for a dynamic initializer. KeyError: 'token' During handling of the above exception, another exception occurred: TraitError Traceback (most recent call last) Cell In[4], line 1 ----> 1 m = mapwidget.Map(center=[20, 0], zoom=2, height='600px') 2 m File /opt/conda/lib/python3.10/site-packages/anywidget/widget.py:62, in AnyWidget.__init__(self, *args, **kwargs) 57 anywidget_traits[_ANYWIDGET_ID_KEY] = t.Unicode( 58 f"{self.__class__.__module__}.{self.__class__.__name__}", 59 ).tag(sync=True) 61 self.add_traits(**anywidget_traits) ---> 62 super().__init__(*args, **kwargs) 63 _register_anywidget_commands(self) File /opt/conda/lib/python3.10/site-packages/ipywidgets/widgets/widget.py:506, in Widget.__init__(self, **kwargs) 503 super().__init__(**kwargs) 505 Widget._call_widget_constructed(self) --> 506 self.open() File /opt/conda/lib/python3.10/site-packages/ipywidgets/widgets/widget.py:525, in Widget.open(self) 523 """Open a comm to the frontend if one isn't already open.""" 524 if self.comm is None: --> 525 state, buffer_paths, buffers = _remove_buffers(self.get_state()) 527 args = dict(target_name='jupyter.widget', 528 data={'state': state, 'buffer_paths': buffer_paths}, 529 buffers=buffers, 530 metadata={'version': __protocol_version__} 531 ) 532 if self._model_id is not None: File /opt/conda/lib/python3.10/site-packages/ipywidgets/widgets/widget.py:615, in Widget.get_state(self, key, drop_defaults) 613 for k in keys: 614 to_json = self.trait_metadata(k, 'to_json', self._trait_to_json) --> 615 value = to_json(getattr(self, k), self) 616 if not drop_defaults or not self._compare(value, traits[k].default_value): 617 state[k] = value File /opt/conda/lib/python3.10/site-packages/traitlets/traitlets.py:703, in TraitType.__get__(self, obj, cls) 701 return self 702 else: --> 703 return self.get(obj, cls) File /opt/conda/lib/python3.10/site-packages/traitlets/traitlets.py:673, in TraitType.get(self, obj, cls) 671 try: 672 obj._cross_validation_lock = True --> 673 value = self._validate(obj, default) 674 finally: 675 obj._cross_validation_lock = _cross_validation_lock File /opt/conda/lib/python3.10/site-packages/traitlets/traitlets.py:738, in TraitType._validate(self, obj, value) 736 return value 737 if hasattr(self, "validate"): --> 738 value = self.validate(obj, value) 739 if obj._cross_validation_lock is False: 740 value = self._cross_validate(obj, value) File /opt/conda/lib/python3.10/site-packages/traitlets/traitlets.py:2536, in Unicode.validate(self, obj, value) 2534 msg = "Could not decode {!r} for unicode trait '{}' of {} instance." 2535 raise TraitError(msg.format(value, self.name, class_of(obj))) from e -> 2536 self.error(obj, value) File /opt/conda/lib/python3.10/site-packages/traitlets/traitlets.py:844, in TraitType.error(self, obj, value, error, info) 838 else: 839 e = "The '{}' trait expected {}, not {}.".format( 840 self.name, 841 self.info(), 842 describe("the", value), 843 ) --> 844 raise TraitError(e) TraitError: The 'token' trait of a Map instance expected a unicode string, not the NoneType None.