python-visualization / folium

Python Data. Leaflet.js Maps.

Home Page:https://python-visualization.github.io/folium/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

pip install of Folium 0.15.1 does not appear to include Realtime Plugin

neiljkeane opened this issue · comments

commented

Describe the bug
A clear and concise description of what the bug is.

Apologies - I am new to Folium and Flask (and github tbh ) so may be making a mistake

If I use pip install folium in a venv environment running python 3.12.0 in vs Code , Realtime plugin is not included in install.
I have also noticed:
The 'Choose version' dropdown on the User guide page shows 'latest' and within the 'Plugins' menu lists the Realtime plugin.
However if I choose v0.15.1 instead of latest , the Realtime plugin is missing from the plugin list.
So it appears that pip is installing version 0.15.1 without the Realtime plugin.

To Reproduce
I am trying the Realtime example to track the international space station from the folium user guide -

import folium
from folium.plugins import Realtime-FAILS HERE

m = folium.Map()

source = folium.JsCode("""
    function(responseHandler, errorHandler) {
        var url = 'https://api.wheretheiss.at/v1/satellites/25544';

        fetch(url)
        .then((response) => {
            return response.json().then((data) => {
                var { id, longitude, latitude } = data;

                return {
                    'type': 'FeatureCollection',
                    'features': [{
                        'type': 'Feature',
                        'geometry': {
                            'type': 'Point',
                            'coordinates': [longitude, latitude]
                        },
                        'properties': {
                            'id': id
                        }
                    }]
                };
            })
        })
        .then(responseHandler)
        .catch(errorHandler);
    }
""")

rt = Realtime(source, interval=10000)
rt.add_to(m)

m
[ Include a code snippet that produces your bug. Make it standalone, we should be able to run it. ]

[ Include a data sample or link to your data if necessary to run the code ]

Expected behavior
A clear and concise description of what you expected to happen.
Realtime plugin to be imported and work with the code.
Error is
from folium.plugins import Realtime
ImportError: cannot import name 'Realtime' from 'folium.plugins' (/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/folium/plugins/init.py

Environment (please complete the following information):

  • Browser [e.g. chrome, firefox]-Chrome
  • Jupyter Notebook or html files?
  • Python version (check it with import sys; print(sys.version_info)) 3.12.0
  • folium version (check it with import folium; print(folium.__version__)) 0.15.1
  • branca version (check it with import branca; print(branca.__version__))0.7.1

Additional context
Add any other context about the problem here.
I tried
pip install --upgrade folium which produced:

Requirement already satisfied: folium in ./realtime/lib/python3.12/site-packages (0.15.1)
Requirement already satisfied: branca>=0.6.0 in ./realtime/lib/python3.12/site-packages (from folium) (0.7.1)
Requirement already satisfied: jinja2>=2.9 in ./realtime/lib/python3.12/site-packages (from folium) (3.1.3)
Requirement already satisfied: numpy in ./realtime/lib/python3.12/site-packages (from folium) (1.26.4)
Requirement already satisfied: requests in ./realtime/lib/python3.12/site-packages (from folium) (2.31.0)
Requirement already satisfied: xyzservices in ./realtime/lib/python3.12/site-packages (from folium) (2023.10.1)
Requirement already satisfied: MarkupSafe>=2.0 in ./realtime/lib/python3.12/site-packages (from jinja2>=2.9->folium) (2.1.5)
Requirement already satisfied: charset-normalizer<4,>=2 in ./realtime/lib/python3.12/site-packages (from requests->folium) (3.3.2)
Requirement already satisfied: idna<4,>=2.5 in ./realtime/lib/python3.12/site-packages (from requests->folium) (3.6)
Requirement already satisfied: urllib3<3,>=1.21.1 in ./realtime/lib/python3.12/site-packages (from requests->folium) (2.2.0)
Requirement already satisfied: certifi>=2017.4.17 in ./realtime/lib/python3.12/site-packages (from requests->folium) (2024.2.2)

Possible solutions
List any solutions you may have come up with.

Any advice gratefully recieved! Folium has worked perfectly for my needs so far - really want to try Realtime as part of a project.-Thanks for your time.

folium is maintained by volunteers. Can you help making a fix for this issue?

The realtime plugin is not yet included in a release. The latest release (0.15.1) is from early December 2023 and the realtime plugin was added just after that. In the meantime, you can just copy the file realtime.py from folium.plugins into your own software tree and import it.

We'll issue a release soon. Stay tuned.

commented

Ok-Thanks

@Conengmo are you planning a new release with these features? Let me know if you need me to mint one.

Thanks for the reminder @ocefpaf! I’ve been busy, but you’re right a release shouldn’t be delayed.

It would give me peace of mind if I can take a look at the changelog first, make sure we mark any breaking changes. I seem to remember there was one, might be wrong. I’ll do it tomorrow and make a draft release!

@ocefpaf I merged some ready stuff and made a draft release, want to check it out and pull the trigger? https://github.com/python-visualization/folium/releases/tag/untagged-0b463559f316d74093e8

@ocefpaf I merged some ready stuff and made a draft release, want to check it out and pull the trigger? https://github.com/python-visualization/folium/releases/tag/untagged-0b463559f316d74093e8

Looks great @Conengmo! Go for it!

Thanks! And done.

I'll update our changes.txt file to point to the release notes in the releases. So we don't have to update that file anymore. Maybe we can even remove it after we made sure all changes are in each release note.