Geemap leaflet support not properly working
fpl opened this issue · 4 comments
Environment Information
Date: Wed Jun 07 12:42:47 2023 CEST
OS : Linux
CPU(s) : 8
Machine : x86_64
Architecture : 64bit
RAM : 31.0 GiB
Environment : Python
File system : ext4
Python 3.9.2 (default, Feb 28 2021, 17:03:44) [GCC 10.2.1 20210110]
geemap : 0.22.1
ee : 0.1.355
ipyleaflet : 0.17.3
folium : 0.14.0
jupyterlab : Module not found
notebook : 6.5.4
ipyevents : 2.0.1
Description
Even a very simple code to show a basemap under Leaflet causes an assertion error and a rendering breakage which requires a kernel restart. The only working rendering engine seems folium currently.
All packages have been installed by user, ignoring any system-wide package, to be sure avoding mixed envs.
What I Did
pip3 install --ignore-installed earthengine-api
pip3 install --ignore-installed geemap
pip3 install --ignore-installed jupyter
jupyter-notebook
_ _ _ _
| | | |_ __ __| |__ _| |_ ___
| |_| | '_ \/ _` / _` | _/ -_)
\___/| .__/\__,_\__,_|\__\___|
|_|
Read the migration plan to Notebook 7 to learn about the new features and the actions to take if you are using extensions.
https://jupyter-notebook.readthedocs.io/en/latest/migrate_to_notebook7.html
Please note that updating to Notebook 7 might break some of your extensions.
[I 12:48:56.215 NotebookApp] Serving notebooks from local directory: /home/frankie
[I 12:48:56.215 NotebookApp] Jupyter Notebook 6.5.4 is running at:
[I 12:48:56.215 NotebookApp] http://localhost:8888/?token=63236e8f6b58e7d121072f0231f20fa80e5d7e3ee47ac424
[I 12:48:56.215 NotebookApp] or http://127.0.0.1:8888/?token=63236e8f6b58e7d121072f0231f20fa80e5d7e3ee47ac424
[I 12:48:56.215 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
[C 12:48:56.235 NotebookApp]
To access the notebook, open this file in a browser:
file:///home/frankie/.local/share/jupyter/runtime/nbserver-65297-open.html
Or copy and paste one of these URLs:
http://localhost:8888/?token=63236e8f6b58e7d121072f0231f20fa80e5d7e3ee47ac424
or http://127.0.0.1:8888/?token=63236e8f6b58e7d121072f0231f20fa80e5d7e3ee47ac424
The code used is very simple
import ee
import geemap
Map = geemap.Map(center=(40, -100), zoom=4)
Map
Now, trying to use the toolset, after a while the whole map freezes
while in the console a series of errors start to appear:
/home/frankie/.local/lib/python3.9/site-packages/nbformat/__init__.py:129: MissingIDFieldWarning: Code cell is missing an id field, this will become a hard error in future nbformat versions. You may want to use `normalize()` on your noteb
ooks before validations (available since nbformat 5.1.4). Previous versions of nbformat are fixing this issue transparently, and will stop doing so in the future.
validate(nb)
/home/frankie/.local/lib/python3.9/site-packages/notebook/services/contents/manager.py:353: MissingIDFieldWarning: Code cell is missing an id field, this will become a hard error in future nbformat versions. You may want to use `normalize
()` on your notebooks before validations (available since nbformat 5.1.4). Previous versions of nbformat are fixing this issue transparently, and will stop doing so in the future.
validate_nb(model['content'])
[E 12:51:52.546 NotebookApp] Uncaught exception, closing connection.
Traceback (most recent call last):
File "/home/frankie/.local/lib/python3.9/site-packages/tornado/iostream.py", line 695, in _handle_events
self._handle_write()
File "/home/frankie/.local/lib/python3.9/site-packages/tornado/iostream.py", line 965, in _handle_write
self._write_buffer.advance(num_bytes)
File "/home/frankie/.local/lib/python3.9/site-packages/tornado/iostream.py", line 182, in advance
assert 0 < size <= self._size
AssertionError
[W 12:51:52.559 NotebookApp] Write error on <socket.socket [closed] fd=-1, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=6>: [Errno 9] Bad file descriptor
[W 12:51:52.564 NotebookApp] zmq message arrived on closed channel
Exception in callback None()
handle: <Handle cancelled>
Traceback (most recent call last):
File "/usr/lib/python3.9/asyncio/events.py", line 80, in _run
self._context.run(self._callback, *self._args)
File "/home/frankie/.local/lib/python3.9/site-packages/tornado/platform/asyncio.py", line 192, in _handle_events
handler_func(fileobj, events)
File "/home/frankie/.local/lib/python3.9/site-packages/tornado/iostream.py", line 695, in _handle_events
self._handle_write()
File "/home/frankie/.local/lib/python3.9/site-packages/tornado/iostream.py", line 965, in _handle_write
self._write_buffer.advance(num_bytes)
File "/home/frankie/.local/lib/python3.9/site-packages/tornado/iostream.py", line 182, in advance
assert 0 < size <= self._size
AssertionError
[I 12:51:52.570 NotebookApp] Starting buffering for 93dcf57d-c7cb-4544-9a99-b92259aeb84f:7cec9a7e132e47ffbc9df4d7326f61f3
[I 12:51:53.611 NotebookApp] Restoring connection for 93dcf57d-c7cb-4544-9a99-b92259aeb84f:7cec9a7e132e47ffbc9df4d7326f61f3
Task exception was never retrieved
future: <Task finished name='Task-749' coro=<WebSocketProtocol13.write_message.<locals>.wrapper() done, defined at /home/frankie/.local/lib/python3.9/site-packages/tornado/websocket.py:1085> exception=WebSocketClosedError()>
Traceback (most recent call last):
File "/home/frankie/.local/lib/python3.9/site-packages/tornado/websocket.py", line 1087, in wrapper
await fut
tornado.iostream.StreamClosedError: Stream is closed
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/lib/python3.9/asyncio/tasks.py", line 256, in __step
result = coro.send(None)
File "/home/frankie/.local/lib/python3.9/site-packages/tornado/websocket.py", line 1089, in wrapper
raise WebSocketClosedError()
tornado.websocket.WebSocketClosedError
[E 12:51:55.964 NotebookApp] Uncaught exception, closing connection.
Traceback (most recent call last):
File "/home/frankie/.local/lib/python3.9/site-packages/tornado/iostream.py", line 695, in _handle_events
self._handle_write()
File "/home/frankie/.local/lib/python3.9/site-packages/tornado/iostream.py", line 965, in _handle_write
self._write_buffer.advance(num_bytes)
File "/home/frankie/.local/lib/python3.9/site-packages/tornado/iostream.py", line 182, in advance
assert 0 < size <= self._size
AssertionError
Exception in callback None()
handle: <Handle cancelled>
Traceback (most recent call last):
File "/usr/lib/python3.9/asyncio/events.py", line 80, in _run
self._context.run(self._callback, *self._args)
File "/home/frankie/.local/lib/python3.9/site-packages/tornado/platform/asyncio.py", line 192, in _handle_events
handler_func(fileobj, events)
File "/home/frankie/.local/lib/python3.9/site-packages/tornado/iostream.py", line 695, in _handle_events
self._handle_write()
File "/home/frankie/.local/lib/python3.9/site-packages/tornado/iostream.py", line 965, in _handle_write
self._write_buffer.advance(num_bytes)
File "/home/frankie/.local/lib/python3.9/site-packages/tornado/iostream.py", line 182, in advance
assert 0 < size <= self._size
AssertionError
[I 12:51:55.965 NotebookApp] Starting buffering for 93dcf57d-c7cb-4544-9a99-b92259aeb84f:7cec9a7e132e47ffbc9df4d7326f61f3
[I 12:51:57.067 NotebookApp] Restoring connection for 93dcf57d-c7cb-4544-9a99-b92259aeb84f:7cec9a7e132e47ffbc9df4d7326f61f3
[I 12:51:57.573 NotebookApp] Replaying 193 buffered messages
[E 12:51:57.691 NotebookApp] Uncaught exception in ZMQStream callback
Traceback (most recent call last):
File "/home/frankie/.local/lib/python3.9/site-packages/zmq/eventloop/zmqstream.py", line 584, in _run_callback
f = callback(*args, **kwargs)
File "/home/frankie/.local/lib/python3.9/site-packages/zmq/eventloop/zmqstream.py", line 308, in stream_callback
return callback(self, msg)
File "/home/frankie/.local/lib/python3.9/site-packages/notebook/services/kernels/handlers.py", line 572, in _on_zmq_reply
super()._on_zmq_reply(stream, msg)
File "/home/frankie/.local/lib/python3.9/site-packages/notebook/base/zmqhandlers.py", line 256, in _on_zmq_reply
self.write_message(msg, binary=isinstance(msg, bytes))
File "/home/frankie/.local/lib/python3.9/site-packages/tornado/websocket.py", line 334, in write_message
return self.ws_connection.write_message(message, binary=binary)
File "/home/frankie/.local/lib/python3.9/site-packages/tornado/websocket.py", line 1081, in write_message
fut = self._write_frame(True, opcode, message, flags=flags)
File "/home/frankie/.local/lib/python3.9/site-packages/tornado/websocket.py", line 1056, in _write_frame
return self.stream.write(frame)
File "/home/frankie/.local/lib/python3.9/site-packages/tornado/iostream.py", line 539, in write
self._handle_write()
File "/home/frankie/.local/lib/python3.9/site-packages/tornado/iostream.py", line 965, in _handle_write
self._write_buffer.advance(num_bytes)
File "/home/frankie/.local/lib/python3.9/site-packages/tornado/iostream.py", line 182, in advance
assert 0 < size <= self._size
AssertionError
[E 12:51:57.692 NotebookApp] Uncaught exception in zmqstream callback
Traceback (most recent call last):
File "/home/frankie/.local/lib/python3.9/site-packages/zmq/eventloop/zmqstream.py", line 634, in _handle_events
self._handle_recv()
File "/home/frankie/.local/lib/python3.9/site-packages/zmq/eventloop/zmqstream.py", line 663, in _handle_recv
self._run_callback(callback, msg)
File "/home/frankie/.local/lib/python3.9/site-packages/zmq/eventloop/zmqstream.py", line 584, in _run_callback
f = callback(*args, **kwargs)
File "/home/frankie/.local/lib/python3.9/site-packages/zmq/eventloop/zmqstream.py", line 308, in stream_callback
return callback(self, msg)
File "/home/frankie/.local/lib/python3.9/site-packages/notebook/services/kernels/handlers.py", line 572, in _on_zmq_reply
super()._on_zmq_reply(stream, msg)
File "/home/frankie/.local/lib/python3.9/site-packages/notebook/base/zmqhandlers.py", line 256, in _on_zmq_reply
self.write_message(msg, binary=isinstance(msg, bytes))
File "/home/frankie/.local/lib/python3.9/site-packages/tornado/websocket.py", line 334, in write_message
return self.ws_connection.write_message(message, binary=binary)
File "/home/frankie/.local/lib/python3.9/site-packages/tornado/websocket.py", line 1081, in write_message
fut = self._write_frame(True, opcode, message, flags=flags)
File "/home/frankie/.local/lib/python3.9/site-packages/tornado/websocket.py", line 1056, in _write_frame
return self.stream.write(frame)
File "/home/frankie/.local/lib/python3.9/site-packages/tornado/iostream.py", line 539, in write
self._handle_write()
File "/home/frankie/.local/lib/python3.9/site-packages/tornado/iostream.py", line 965, in _handle_write
self._write_buffer.advance(num_bytes)
File "/home/frankie/.local/lib/python3.9/site-packages/tornado/iostream.py", line 182, in advance
assert 0 < size <= self._size
AssertionError
[E 12:51:57.693 NotebookApp] Exception in callback functools.partial(<function ZMQStream._update_handler.<locals>.<lambda> at 0x7f72843e1310>)
Traceback (most recent call last):
File "/home/frankie/.local/lib/python3.9/site-packages/tornado/ioloop.py", line 738, in _run_callback
ret = callback()
File "/home/frankie/.local/lib/python3.9/site-packages/zmq/eventloop/zmqstream.py", line 718, in <lambda>
self.io_loop.add_callback(lambda: self._handle_events(self.socket, 0))
File "/home/frankie/.local/lib/python3.9/site-packages/zmq/eventloop/zmqstream.py", line 634, in _handle_events
self._handle_recv()
File "/home/frankie/.local/lib/python3.9/site-packages/zmq/eventloop/zmqstream.py", line 663, in _handle_recv
self._run_callback(callback, msg)
File "/home/frankie/.local/lib/python3.9/site-packages/zmq/eventloop/zmqstream.py", line 584, in _run_callback
f = callback(*args, **kwargs)
File "/home/frankie/.local/lib/python3.9/site-packages/zmq/eventloop/zmqstream.py", line 308, in stream_callback
return callback(self, msg)
File "/home/frankie/.local/lib/python3.9/site-packages/notebook/services/kernels/handlers.py", line 572, in _on_zmq_reply
super()._on_zmq_reply(stream, msg)
File "/home/frankie/.local/lib/python3.9/site-packages/notebook/base/zmqhandlers.py", line 256, in _on_zmq_reply
self.write_message(msg, binary=isinstance(msg, bytes))
File "/home/frankie/.local/lib/python3.9/site-packages/tornado/websocket.py", line 334, in write_message
return self.ws_connection.write_message(message, binary=binary)
File "/home/frankie/.local/lib/python3.9/site-packages/tornado/websocket.py", line 1081, in write_message
fut = self._write_frame(True, opcode, message, flags=flags)
File "/home/frankie/.local/lib/python3.9/site-packages/tornado/websocket.py", line 1056, in _write_frame
return self.stream.write(frame)
File "/home/frankie/.local/lib/python3.9/site-packages/tornado/iostream.py", line 539, in write
self._handle_write()
File "/home/frankie/.local/lib/python3.9/site-packages/tornado/iostream.py", line 965, in _handle_write
self._write_buffer.advance(num_bytes)
File "/home/frankie/.local/lib/python3.9/site-packages/tornado/iostream.py", line 182, in advance
assert 0 < size <= self._size
AssertionError
from now on, no map can be rendered, even re-executing the cells. A clean & restart is required. Often at that point it suffices clckiing on the toolbar wrench icon to trigger the crash.
Just for completeness this is Debian 11, but even under Debian 12 with Python 3.11 the problem is identical. It could be a problem triggered by tornado changes, but I'm not sure.
Try using ipyleaflet directly to see the same error occurrs
import ipyleaflet
Map = ipyleaflet.Map(center=(40, -100), zoom=4)
Map
Yes, it shows the same exceptions and stop to visualize new maps after the first one. So this seems a current problem of ipyleaflet, apparently.
Could you open an issue on the ipyleaflet repo?