jupyter-widgets / ipywidgets

Interactive Widgets for the Jupyter Notebook
https://ipywidgets.readthedocs.io
BSD 3-Clause "New" or "Revised" License
3.14k stars 949 forks source link

interactive_output does not update folium map #3595

Closed iacisme closed 1 year ago

iacisme commented 2 years ago

Description

Hi guys;

I'm using interactive output with folium and this is the output I get:

image

The widgets show up how I expected them to be laid out, but I get no map output.

I can run the exact same function using the @widgets.interact decorator and it works perfectly.

Below is a screen shot:

image

I want to use widgets.interactive_output because I want to layout the controls.

Reproduce

  1. Create a simple map function using the folium library
  2. Using widgets.interactive_output, create some text boxes and link them to function parameters
  3. Run and try to display the controls + map
  4. You should see your controls, but not the map

I know widgets.interactive_output works on my setup because I've used it with plotly and have no issues. It's just with folium.

Expected behavior

I was expecting both a my widgets and map to be displayed.

Context

Troubleshoot Output
Paste the output from running `jupyter troubleshoot` from the command line here.
You may want to sanitize the paths in the output.

(data_science) VENOEN_DESKTOP:~$ jupyter troubleshoot
$PATH:
    /home/user/.virtualenvs/data_science/bin
    /home/user/.local/bin
    /usr/local/sbin
    /usr/local/bin
    /usr/sbin
    /usr/bin
    /sbin
    /bin
    /usr/games
    /usr/local/games
    /snap/bin
    /snap/bin
    /home/user/00_Chrome_Driver

sys.path:
    /home/user/.virtualenvs/data_science/bin
    /usr/lib/python310.zip
    /usr/lib/python3.10
    /usr/lib/python3.10/lib-dynload
    /home/user/.virtualenvs/data_science/lib/python3.10/site-packages

sys.executable:
    /home/user/.virtualenvs/data_science/bin/python

sys.version:
    3.10.4 (main, Jun 29 2022, 12:14:53) [GCC 11.2.0]

platform.platform():
    Linux-5.15.0-47-generic-x86_64-with-glibc2.35

which -a jupyter:
    /home/user/.virtualenvs/data_science/bin/jupyter

pip list:
    Package                   Version
    ------------------------- ------------
    ansi2html                 1.8.0
    anyio                     3.6.1
    argon2-cffi               21.3.0
    argon2-cffi-bindings      21.2.0
    asttokens                 2.0.8
    async-generator           1.10
    attrs                     22.1.0
    Babel                     2.10.3
    backcall                  0.2.0
    beautifulsoup4            4.11.1
    bleach                    5.0.1
    bqplot                    0.12.36
    branca                    0.5.0
    Brotli                    1.0.9
    cachetools                5.2.0
    certifi                   2022.6.15.1
    cffi                      1.15.1
    charset-normalizer        2.1.1
    click                     8.1.3
    colour                    0.1.5
    cycler                    0.11.0
    dash                      2.6.1
    dash-bootstrap-components 1.2.1
    dash-core-components      2.0.0
    dash-html-components      2.0.0
    dash-table                5.0.0
    debugpy                   1.6.3
    decorator                 5.1.1
    defusedxml                0.7.1
    earthengine-api           0.1.323
    ee-extra                  0.0.14
    entrypoints               0.4
    executing                 1.0.0
    fastjsonschema            2.16.1
    ffmpeg-python             0.2.0
    filelock                  3.8.0
    Flask                     2.2.2
    Flask-Compress            1.12
    folium                    0.12.1.post1
    fonttools                 4.37.1
    future                    0.18.2
    gdown                     4.5.1
    geeadd                    0.5.6
    geemap                    0.17.0
    geocoder                  1.38.1
    geographiclib             1.52
    geojson                   2.5.0
    geopy                     2.2.0
    google-api-core           2.10.0
    google-api-python-client  1.12.11
    google-auth               2.11.0
    google-auth-httplib2      0.1.0
    google-cloud-core         2.3.2
    google-cloud-storage      2.5.0
    google-crc32c             1.5.0
    google-resumable-media    2.3.3
    googleapis-common-protos  1.56.4
    greenlet                  1.1.3
    h11                       0.13.0
    html5lib                  1.1
    httplib2                  0.20.4
    httplib2shim              0.0.3
    ibm-db                    3.1.3
    ibm-db-sa                 0.3.8
    idna                      3.3
    ipyevents                 2.0.1
    ipyfilechooser            0.6.0
    ipykernel                 6.15.2
    ipyleaflet                0.17.1
    ipython                   8.5.0
    ipython-genutils          0.2.0
    ipython-sql               0.4.1
    ipytree                   0.2.2
    ipywidgets                8.0.2
    itsdangerous              2.1.2
    jedi                      0.18.1
    Jinja2                    3.1.2
    joblib                    1.1.0
    json5                     0.9.10
    jsonschema                4.16.0
    jupyter_client            7.3.5
    jupyter-core              4.11.1
    jupyter-dash              0.4.2
    jupyter-server            1.18.1
    jupyterlab                3.4.6
    jupyterlab-pygments       0.2.2
    jupyterlab_server         2.15.1
    jupyterlab-widgets        3.0.3
    kiwisolver                1.4.4
    logzero                   1.7.0
    lxml                      4.9.1
    MarkupSafe                2.1.1
    matplotlib                3.5.3
    matplotlib-inline         0.1.6
    missingno                 0.5.1
    mistune                   2.0.4
    nbclassic                 0.4.3
    nbclient                  0.6.8
    nbconvert                 7.0.0
    nbformat                  5.4.0
    nest-asyncio              1.5.5
    notebook                  6.4.12
    notebook-shim             0.1.0
    numpy                     1.23.3
    outcome                   1.2.0
    packaging                 21.3
    pandas                    1.4.4
    pandocfilters             1.5.0
    parso                     0.8.3
    pexpect                   4.8.0
    pickleshare               0.7.5
    Pillow                    9.2.0
    pip                       22.2.2
    plotly                    5.10.0
    prettytable               0.7.2
    prometheus-client         0.14.1
    prompt-toolkit            3.0.31
    protobuf                  4.21.5
    psutil                    5.9.2
    ptyprocess                0.7.0
    pure-eval                 0.2.2
    pyasn1                    0.4.8
    pyasn1-modules            0.2.8
    pycparser                 2.21
    PyCRS                     1.0.2
    Pygments                  2.13.0
    pyparsing                 3.0.9
    pyrsistent                0.18.1
    pyshp                     2.3.1
    PySocks                   1.7.1
    python-box                6.0.2
    python-dateutil           2.8.2
    pytz                      2022.2.1
    pyzmq                     23.2.1
    ratelim                   0.1.6
    requests                  2.28.1
    retrying                  1.3.3
    rsa                       4.9
    sankee                    0.2.0
    scikit-learn              1.1.2
    scipy                     1.9.1
    scooby                    0.6.0
    seaborn                   0.12.0
    selenium                  4.4.3
    Send2Trash                1.8.0
    setuptools                65.3.0
    six                       1.16.0
    sniffio                   1.3.0
    sortedcontainers          2.4.0
    soupsieve                 2.3.2.post1
    SQLAlchemy                1.4.41
    sqlparse                  0.4.2
    stack-data                0.5.0
    tenacity                  8.0.1
    terminado                 0.15.0
    threadpoolctl             3.1.0
    tinycss2                  1.1.1
    tornado                   6.2
    tqdm                      4.64.1
    traitlets                 5.3.0
    traittypes                0.2.1
    trio                      0.21.0
    trio-websocket            0.9.2
    uritemplate               3.0.1
    urllib3                   1.26.12
    vega-datasets             0.9.0
    wcwidth                   0.2.5
    webencodings              0.5.1
    websocket-client          1.4.1
    Werkzeug                  2.2.2
    wheel                     0.37.1
    whitebox                  2.1.4
    whiteboxgui               0.7.0
    widgetsnbextension        4.0.3
    wsproto                   1.2.0
    xyzservices               2022.6.0
Command Line Output

The output is too big to paste here, I've tried attaching it as a file but it doesn't link.

Browser Output
Paste the output from your browser Javascript console here.

If using JupyterLab

Installed Labextensions

(data_science) user@VENOEN_DESKTOP:~$ jupyter labextension list
JupyterLab v3.4.6
/home/user/.virtualenvs/data_science/share/jupyter/labextensions
        jupyterlab_pygments v0.2.2 enabled OK (python, jupyterlab_pygments)
        jupyterlab-plotly v5.10.0 enabled OK
        bqplot v0.5.37 enabled OK (python, bqplot)
        ipytree v0.2.2 enabled OK
        ipyevents v2.0.1 enabled OK
        jupyter-leaflet v0.17.1 enabled OK
        @jupyter-widgets/jupyterlab-manager v5.0.3 enabled OK (python, jupyterlab_widgets)

Other labextensions (built into JupyterLab)
   app dir: /home/user/.virtualenvs/data_science/share/jupyter/lab
        jupyterlab-dash v0.4.2 enabled OK

jeffliu-LL commented 1 year ago

I had this issue too, but calling display(m) inside your create_a_simple_map function, where m is your folium object fixed it for me.

iacisme commented 1 year ago

Thank you @jeffliu-LL this resolved my issue.

I really appreciate your input, thank you!