Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

when launching tastymap ui: AttributeError: module 'panel.widgets' has no attribute 'ColorMap' #14

Open
JulianGiles opened this issue Dec 12, 2023 · 6 comments

Comments

@JulianGiles
Copy link

ALL software version info

# Name                    Version                   Build  Channel
panel                     1.2.3              pyhd8ed1ab_0    conda-forge
tastymap                  0.3.0                    pypi_0    pypi
bokeh                     3.2.2              pyhd8ed1ab_0    conda-forge
python                    3.11.5          hab00c5b_0_cpython    conda-forge
jupyter                   1.0.0           py311h38be061_8    conda-forge
notebook                  7.0.4              pyhd8ed1ab_0    conda-forge

Description of expected behavior and the observed behavior

When running tastymap ui in the terminal I get:

Traceback (most recent call last):
  File "/user/jgiles/mambaforge/envs/wradlib4/bin/tastymap", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/user/jgiles/mambaforge/envs/wradlib4/lib/python3.11/site-packages/tastymap/cli.py", line 12, in main
    TastyKitchen().serve(port=8888, show=True)
    ^^^^^^^^^^^^^^
  File "/user/jgiles/mambaforge/envs/wradlib4/lib/python3.11/site-packages/tastymap/ui.py", line 147, in __init__
    self.cmap_input = pn.widgets.ColorMap(
                      ^^^^^^^^^^^^^^^^^^^
AttributeError: module 'panel.widgets' has no attribute 'ColorMap'

Complete, minimal, self-contained example code that reproduces the issue

# in a terminal
tastymap ui
@ahuang11
Copy link
Owner

Thanks! Panel released ColorMap widget in v1.3.0 so if you upgrade Panel it'll work. On my end, I need to pin panel>=1.3.0.

@JulianGiles
Copy link
Author

ah, gotcha. I have installed again in a new env, however now I get another error :(

Launching server at http://localhost:8888
Uncaught exception GET / (127.0.0.1)
HTTPServerRequest(protocol='http', host='localhost:8888', method='GET', uri='/', version='HTTP/1.1', remote_ip='127.0.0.1')
Traceback (most recent call last):
  File "/user/jgiles/mambaforge/envs/tastymapui/lib/python3.12/site-packages/panel/pane/plot.py", line 341, in _data
    obj.set_dpi(self.dpi)
  File "/user/jgiles/mambaforge/envs/tastymapui/lib/python3.12/site-packages/matplotlib/figure.py", line 3088, in set_dpi
    self.dpi = val
    ^^^^^^^^
  File "/user/jgiles/mambaforge/envs/tastymapui/lib/python3.12/site-packages/matplotlib/figure.py", line 2776, in _set_dpi
    self.set_size_inches(w, h, forward=forward)
  File "/user/jgiles/mambaforge/envs/tastymapui/lib/python3.12/site-packages/matplotlib/figure.py", line 3044, in set_size_inches
    manager.resize(*(size * self.dpi).astype(int))
  File "/user/jgiles/mambaforge/envs/tastymapui/lib/python3.12/site-packages/matplotlib/backends/_backend_tk.py", line 546, in resize
    self.canvas._tkcanvas.configure(width=width, height=height)
  File "/user/jgiles/mambaforge/envs/tastymapui/lib/python3.12/tkinter/__init__.py", line 1702, in configure
    return self._configure('configure', cnf, kw)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/user/jgiles/mambaforge/envs/tastymapui/lib/python3.12/tkinter/__init__.py", line 1692, in _configure
    self.tk.call(_flatten((self._w, cmd)) + self._options(cnf))
_tkinter.TclError: invalid command name ".!canvas"

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/user/jgiles/mambaforge/envs/tastymapui/lib/python3.12/site-packages/tornado/web.py", line 1786, in _execute
    result = await result
             ^^^^^^^^^^^^
  File "/user/jgiles/mambaforge/envs/tastymapui/lib/python3.12/site-packages/panel/io/server.py", line 586, in get
    session = await self.get_session()
              ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/user/jgiles/mambaforge/envs/tastymapui/lib/python3.12/site-packages/panel/io/server.py", line 475, in get_session
    session = await super().get_session()
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/user/jgiles/mambaforge/envs/tastymapui/lib/python3.12/site-packages/bokeh/server/views/session_handler.py", line 145, in get_session
    session = await self.application_context.create_session_if_needed(session_id, self.request, token)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/user/jgiles/mambaforge/envs/tastymapui/lib/python3.12/site-packages/bokeh/server/contexts.py", line 240, in create_session_if_needed
    self._application.initialize_document(doc)
  File "/user/jgiles/mambaforge/envs/tastymapui/lib/python3.12/site-packages/panel/io/server.py", line 411, in initialize_document
    super().initialize_document(doc)
  File "/user/jgiles/mambaforge/envs/tastymapui/lib/python3.12/site-packages/bokeh/application/application.py", line 190, in initialize_document
    h.modify_document(doc)
  File "/user/jgiles/mambaforge/envs/tastymapui/lib/python3.12/site-packages/bokeh/application/handlers/function.py", line 140, in modify_document
    self._func(doc)
  File "/user/jgiles/mambaforge/envs/tastymapui/lib/python3.12/site-packages/panel/io/server.py", line 152, in _eval_panel
    doc = panel._modify_doc(server_id, title, doc, location)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/user/jgiles/mambaforge/envs/tastymapui/lib/python3.12/site-packages/panel/viewable.py", line 316, in _modify_doc
    return self.server_doc(doc, title, location) # type: ignore
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/user/jgiles/mambaforge/envs/tastymapui/lib/python3.12/site-packages/panel/template/base.py", line 480, in server_doc
    return self._init_doc(doc, title=title, location=location)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/user/jgiles/mambaforge/envs/tastymapui/lib/python3.12/site-packages/panel/template/base.py", line 731, in _init_doc
    document = super()._init_doc(doc, comm, title, notebook, location)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/user/jgiles/mambaforge/envs/tastymapui/lib/python3.12/site-packages/panel/template/base.py", line 217, in _init_doc
    model = obj.get_root(document, comm, preprocess=False)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/user/jgiles/mambaforge/envs/tastymapui/lib/python3.12/site-packages/panel/layout/base.py", line 309, in get_root
    root = super().get_root(doc, comm, preprocess)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/user/jgiles/mambaforge/envs/tastymapui/lib/python3.12/site-packages/panel/viewable.py", line 670, in get_root
    root = self._get_model(doc, comm=comm)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/user/jgiles/mambaforge/envs/tastymapui/lib/python3.12/site-packages/panel/layout/base.py", line 177, in _get_model
    objects, _ = self._get_objects(model, [], doc, root, comm)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/user/jgiles/mambaforge/envs/tastymapui/lib/python3.12/site-packages/panel/layout/tabs.py", line 211, in _get_objects
    rendered[pref] = child = pane._get_model(doc, root, model, comm)
                             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/user/jgiles/mambaforge/envs/tastymapui/lib/python3.12/site-packages/panel/layout/base.py", line 177, in _get_model
    objects, _ = self._get_objects(model, [], doc, root, comm)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/user/jgiles/mambaforge/envs/tastymapui/lib/python3.12/site-packages/panel/layout/base.py", line 159, in _get_objects
    child = pane._get_model(doc, root, model, comm)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/user/jgiles/mambaforge/envs/tastymapui/lib/python3.12/site-packages/panel/pane/plot.py", line 311, in _get_model
    return self._img_type._get_model(self, doc, root, parent, comm)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/user/jgiles/mambaforge/envs/tastymapui/lib/python3.12/site-packages/panel/pane/base.py", line 496, in _get_model
    model = self._bokeh_model(**self._get_properties(doc))
                                ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/user/jgiles/mambaforge/envs/tastymapui/lib/python3.12/site-packages/panel/reactive.py", line 581, in _get_properties
    properties = self._process_param_change(params)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/user/jgiles/mambaforge/envs/tastymapui/lib/python3.12/site-packages/panel/pane/base.py", line 519, in _process_param_change
    params.update(self._transform_object(params.pop('object')))
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/user/jgiles/mambaforge/envs/tastymapui/lib/python3.12/site-packages/panel/pane/plot.py", line 293, in _transform_object
    return self._img_type._transform_object(self, obj)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/user/jgiles/mambaforge/envs/tastymapui/lib/python3.12/site-packages/panel/pane/image.py", line 196, in _transform_object
    data = self._data(obj)
           ^^^^^^^^^^^^^^^
  File "/user/jgiles/mambaforge/envs/tastymapui/lib/python3.12/site-packages/panel/pane/plot.py", line 343, in _data
    raise Exception("The Matplotlib backend is not configured. Try adding `matplotlib.use('agg')`") from ex
Exception: The Matplotlib backend is not configured. Try adding `matplotlib.use('agg')`

@JulianGiles
Copy link
Author

Maybe the issue is related to installation with mamba/conda and pip. It would be nice to have tastymap in conda so it is possible to install everything with mamba/conda :)

@ahuang11
Copy link
Owner

Can you share the version of panel and matplotlib? I'll try to reproduce.

Yes, eventually I should get it released on conda. Feel free to help me do that too :D

@ahuang11
Copy link
Owner

In the meantime, you can try the UI here: https://huggingface.co/spaces/ahuang11/tastykitchen

@JulianGiles
Copy link
Author

I'm on

matplotlib                3.8.2                    pypi_0    pypi
panel                     1.3.4              pyhd8ed1ab_0    conda-forge

I'll try it on that link, thanks so much!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants