can you fix this pyscript code, it crashed :(



Panel DeckGL NYC Taxi Demo
1


Traceback (most recent call last):
  File "/home/pyodide/pyscript/_internal.py", line 104, in run_pyscript
    result = eval_code(code, globals=__main__.__dict__)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/lib/python311.zip/_pyodide/_base.py", line 468, in eval_code
    .run(globals, locals)
     ^^^^^^^^^^^^^^^^^^^^
  File "/lib/python311.zip/_pyodide/_base.py", line 310, in run
    coroutine = eval(self.code, globals, locals)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<exec>", line 1, in <module>
  File "/lib/python3.11/site-packages/panel/__init__.py", line 48, in <module>
    from . import layout # noqa
    ^^^^^^^^^^^^^^^^^^^^
  File "/lib/python3.11/site-packages/panel/layout/__init__.py", line 31, in <module>
    from .accordion import Accordion # noqa
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/lib/python3.11/site-packages/panel/layout/accordion.py", line 5, in <module>
    from .base import NamedListPanel
  File "/lib/python3.11/site-packages/panel/layout/base.py", line 17, in <module>
    from ..io.model import hold
  File "/lib/python3.11/site-packages/panel/io/__init__.py", line 21, in <module>
    from .pyodide import serve
  File "/lib/python3.11/site-packages/panel/io/pyodide.py", line 17, in <module>
    from ..config import config
  File "/lib/python3.11/site-packages/panel/config.py", line 425, in <module>
    config = _config(**{k: None if p.allow_None else getattr(_config, k)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/lib/python3.11/site-packages/panel/config.py", line 224, in __init__
    super().__init__(**params)
  File "/lib/python3.11/site-packages/param/parameterized.py", line 4179, in __init__
    if not isinstance(self._param__private, _InstancePrivate):
                      ^^^^^^^^^^^^^^^^^^^^
  File "/lib/python3.11/site-packages/panel/config.py", line 297, in __getattribute__
    init = super().__getattribute__('initialized')
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: '_config' object has no attribute 'initialized'
View Code
index.html

    
        
                <py-config>
                    packages = [
                      "https://cdn.holoviz.org/panel/0.14.3/dist/wheels/bokeh-2.4.3-py3-none-any.whl",
                      "numpy",
                      "pandas",
                      "panel==0.13.1"
                    ]
                    plugins = [
                      "https://pyscript.net/latest/plugins/python/py_tutor.py"
                    ]
                </py-config>

                <py-script>
                    import panel as pn
                    import pandas as pd
                    import param

                    from pyodide.http import open_url

                    MAPBOX_KEY = "pk.eyJ1IjoicGFuZWxvcmciLCJhIjoiY2s1enA3ejhyMWhmZjNobjM1NXhtbWRrMyJ9.B_frQsAVepGIe-HiOJeqvQ"

                    class App(param.Parameterized):

                        data = param.DataFrame(precedence=-1)

                        view = param.DataFrame(precedence=-1)

                        arc_view = param.DataFrame(precedence=-1)

                        radius = param.Integer(default=50, bounds=(20, 1000))

                        elevation = param.Integer(default=10, bounds=(0, 50))

                        hour = param.Integer(default=0, bounds=(0, 23))

                        speed = param.Integer(default=1, bounds=(0, 10), precedence=-1)

                        play = param.Event(label='▷')

                        def __init__(self, **params):
                            self.deck_gl = None
                            super().__init__(**params)
                            self.deck_gl = pn.pane.DeckGL(
                                dict(self.spec),
                                mapbox_api_key=MAPBOX_KEY,
                                throttle={'click': 10},
                                sizing_mode='stretch_both',
                                margin=0
                            )
                            self.deck_gl.param.watch(self._update_arc_view, 'click_state')
                            self._playing = False
                            self._cb = pn.state.add_periodic_callback(
                                self._update_hour, 1000//self.speed, start=False
                            )

                        @property
                        def spec(self):
                            return {
                                "initialViewState": {
                                    "bearing": 0,
                                    "latitude": 40.7,
                                    "longitude": -73.9,
                                    "maxZoom": 15,
                                    "minZoom": 5,
                                    "pitch": 40.5,
                                    "zoom": 11
                                },
                                "layers": [self.hex_layer, self.arc_layer],
                                "mapStyle": "mapbox://styles/mapbox/dark-v9",
                                "views": [
                                    {"@@type": "MapView", "controller": True}
                                ]
                            }

                        @property
                        def hex_layer(self):
                            return {
                                "@@type": "HexagonLayer",
                                "autoHighlight": True,
                                "coverage": 1,
                                "data": self.data if self.view is None else self.view,
                                "elevationRange": [0, 100],
                                "elevationScale": self.elevation,
                                "radius": self.radius,
                                "extruded": True,
                                "getPosition": "@@=[pickup_x, pickup_y]",
                                "id": "8a553b25-ef3a-489c-bbe2-e102d18a3211"
                            }

                        @property
                        def arc_layer(self):
                            return {
                                "@@type": "ArcLayer",
                                "id": 'arc-layer',
                                "data": self.arc_view,
                                "pickable": True,
                                "getWidth": 1,
                                "getSourcePosition": "@@=[pickup_x, pickup_y]",
                                "getTargetPosition": "@@=[dropoff_x, dropoff_y]",
                                "getSourceColor": [0, 255, 0, 180],
                                "getTargetColor": [240, 100, 0, 180]
                            }

                        def _update_hour(self):
                            self.hour = (self.hour+1) % 24

                        @param.depends('view', watch=True)
                        def _update_arc_view(self, event=None):
                            data = self.data if self.view is None else self.view
                            if not self.deck_gl or not self.deck_gl.click_state:
                                self.arc_view = data.iloc[:0]
                                return
                            lon, lat = self.deck_gl.click_state['coordinate']
                            tol = 0.001
                            self.arc_view = data[
                                (df.pickup_x&gt;=float(lon-tol)) &amp;
                                (df.pickup_x&lt;=float(lon+tol)) &amp;
                                (df.pickup_y&gt;=float(lat-tol)) &amp;
                                (df.pickup_y&lt;=float(lat+tol))
                            ]

                        @param.depends('hour', watch=True, on_init=True)
                        def _update_hourly_view(self):
                            self.view = self.data[self.data.hour==self.hour]

                        @param.depends('speed', watch=True)
                        def _update_speed(self):
                            self._cb.period = 1000//self.speed

                        @param.depends('play', watch=True)
                        def _play_pause(self):
                            if self._playing:
                                self._cb.stop()
                                self.param.play.label = '▷'
                                self.param.speed.precedence = -1
                            else:
                                self._cb.start()
                                self.param.play.label = '❚❚'
                                self.param.speed.precedence = 1
                            self._playing = not self._playing

                        @param.depends('view', 'radius', 'elevation', 'arc_view', watch=True)
                        def update_spec(self):
                            self.deck_gl.object = dict(self.spec)

                    url = 'https://s3.eu-west-1.amazonaws.com/assets.holoviews.org/data/nyc_taxi_wide.csv'
                    df = pd.read_csv(open_url(url))
                    app = App(data=df)
                    controls = pn.Param(app.param, sizing_mode='stretch_width', show_name=False)

                    app.deck_gl.servable(target='plot')
                    controls.servable(target='widgets');
                </py-script>
            
    



the error code it gave was, 


Traceback (most recent call last):
  File "/home/pyodide/pyscript/_internal.py", line 104, in run_pyscript
    result = eval_code(code, globals=__main__.__dict__)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/lib/python311.zip/_pyodide/_base.py", line 468, in eval_code
    .run(globals, locals)
     ^^^^^^^^^^^^^^^^^^^^
  File "/lib/python311.zip/_pyodide/_base.py", line 310, in run
    coroutine = eval(self.code, globals, locals)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<exec>", line 1, in <module>
  File "/lib/python3.11/site-packages/panel/__init__.py", line 48, in <module>
    from . import layout # noqa
    ^^^^^^^^^^^^^^^^^^^^
  File "/lib/python3.11/site-packages/panel/layout/__init__.py", line 31, in <module>
    from .accordion import Accordion # noqa
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/lib/python3.11/site-packages/panel/layout/accordion.py", line 5, in <module>
    from .base import NamedListPanel
  File "/lib/python3.11/site-packages/panel/layout/base.py", line 17, in <module>
    from ..io.model import hold
  File "/lib/python3.11/site-packages/panel/io/__init__.py", line 21, in <module>
    from .pyodide import serve
  File "/lib/python3.11/site-packages/panel/io/pyodide.py", line 17, in <module>
    from ..config import config
  File "/lib/python3.11/site-packages/panel/config.py", line 425, in <module>
    config = _config(**{k: None if p.allow_None else getattr(_config, k)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/lib/python3.11/site-packages/panel/config.py", line 224, in __init__
    super().__init__(**params)
  File "/lib/python3.11/site-packages/param/parameterized.py", line 4179, in __init__
    if not isinstance(self._param__private, _InstancePrivate):
                      ^^^^^^^^^^^^^^^^^^^^
  File "/lib/python3.11/site-packages/panel/config.py", line 297, in __getattribute__
    init = super().__getattribute__('initialized')
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: '_config' object has no attribute 'initialized'



I want you to go line by line for the error code and then make a state of the problem like and then decide whether this updates the state of the problem or not and this is how I want you to troubleshoot it because we're going to have to rewrite quite a bit. So we need to look take a look at each line and try to get to the root cause of the problem. Okay, so let's let's troubleshoot this. Let's write it in PyScript and then let's make a plan on how we can just use plain vim and an HTML file with PyScript to re-implement this in order for it to work. It's one of the official demos for PyScript that used like NYC Taxi data visualization.