Open giswqs opened 2 years ago
CC @jweill-aws
Thanks for reporting this! I've informed the SageMaker Studio Lab team.
Hi- try installing with a % instead of a !. See Studio Lab FAQ below.
Q: How can I install open-source Python packages?
To install Python packages, you can use ‘%pip install
I just uninstalled ipyeaflet and reinstalled using %conda install ipyleaflet -c conda-forge -y
. Restarted the kernel and still got the same error. Is there a way to do a factory reset of my account so that I can start from scratch to install ipyleaflet?
@giswqs There is no "reset" button in Studio Lab just yet. If you would like to reset your account, you can delete your account and register again. You will not have to wait for another approval as long as you use the same information when you register again.
I just uninstalled ipyeaflet and reinstalled using
%conda install ipyleaflet -c conda-forge -y
. Restarted the kernel and still got the same error. Is there a way to do a factory reset of my account so that I can start from scratch to install ipyleaflet?
I'll just point out that your labextension list indicates it installed ipywidgets 8, and ipyleaflet is not yet compatible with ipywidgets 8. That may be why it had an error displaying. We're working on ipywidgets 8 compatibility over in #968, and it should be coming soon.
@jasongrout where did you see ipywidgets 8? I only see from https://user-images.githubusercontent.com/5016453/185829006-bc1d5b25-03ad-4b32-8270-4a063547b9d1.png:
JupyterLab v3.2.4 /home/.../labextensions ipytree v0.2.1 ipyevents v1.9.0 bqplot v0.5.32 jupyterlab-plotly v5.9.0 jupyterlab_pygments v0.2.2 jupyter-leaflet v0.17.0 @jupyter-widgets/jupyterlab-manager v5.0.2 @here/map-widget-for-jupyter v1.1.3
@jupyter-widgets/jupyterlab-manager v5.0.2
This is the version of the widgets manager that comes with ipywidgets 8.
FYI, ipyleaflet now supports ipywidgets 8.
@MicheleMonclova @JasonWeill I tested ipyleaflet on three SageMaker platforms, including SageMaker, SageMaker EC2 notebook instance, and SageMaker Studio Lab. Unfortunately, none of them work. Any advice?
Different error in 2024. ipyleaflet-0.17.4, jupyterlab-4.1.6.
For solara, we did some special checking if the jupyter server actually serves the extension:
%pip install solara ipyleaflet
import solara
# a bug in solara, so we monkey patch it
solara._using_solara_server = lambda: False
# pass in updated module names (next release of solara we should also fix this)
libraries_extra = [
{"python": "bqplot", "classic": "bqplot/extension", "lab": "bqplot"},
{"python": "ipyvolume", "classic": "ipyvolume/extension", "lab": "ipyvolume"},
{"python": "ipywebrtc", "classic": "jupyter-webrtc", "lab": "jupyter-webrtc"},
{"python": "ipyleaflet", "classic": "ipyleaflet/extension", "lab": "jupyter-leaflet"},
]
solara.checks.check_jupyter(silent=False, force=True, extra=True, libraries_extra=libraries_extra)
It should look like this:
After running
!/home/ec2-user/anaconda3/envs/JupyterSystemEnv/bin/python3.10 -m pip install ipyvuetify ipyvue bqplot ipyvolume ipywebrtc ipyleaflet
And a page refresh, you should see:
Now ipyleaflet works!
Let me know if that solves your problems.
I tried it on SageMaker Studio Lab. I can see that now the extentions have been installed successfully, but ipyleaflet still does not work. Any advice?
What do you see in the js console?
With normal sagemaker (Jupyter Lab), I have it working
The _JUPYTERLAB
variable that I print out in the js console (which contains _JUPYTERLAB["jupyter-leaflet"]), is what we use to determine if it is installed as an extensions in the frontend or not.
I'm out of ideas now, because it should just work. I asked for a Sagemager Studio Lab account, maybe I can debug it if I get it.
@maartenbreddels You are a life saver! I can confirm that it works with the normal SageMaker now. Not sure what's the issue with the Studio Lab, but at least the normal SageMaker is working now. This is exciting!
And MapLibre also works now!
Great. There are quite a few gems in solara :)
I'll fix solara, because it should do this check always when importing. It would be great if all ipywidget libraries would be checked this way.
That would be nice! This have been a long standing for over two years. So happy to see that we finally have a solution. Thank you very much.
Ok, I got it working on Studio Lab as well.
Include this patch:
import sys
import os
def getcmdline(pid):
# for linux
if sys.platform == "linux":
# if /proc/{pid}/exe exists, follow the symlink
if os.path.exists(f"/proc/{pid}/exe"):
return os.readlink(f"/proc/{pid}/exe")
with open(f"/proc/{pid}/cmdline", "rb") as f:
return f.read().split(b"\00")[0].decode("utf-8")
elif sys.platform == "darwin":
return subprocess.check_output(["ps", "-o", "command=", "-p", str(pid)]).split(b"\n")[0].split(b" ")[0].decode("utf-8")
elif sys.platform == "win32":
return subprocess.check_output(["wmic", "process", "get", "commandline", "/format:list"]).split(b"\n")[0].split(b" ")[0].decode("utf-8")
else:
raise ValueError(f"Unsupported platform: {sys.platform}")
solara.checks.getcmdline = getcmdline
After that, the install command was correct, and executed in a cell
!/home/studio-lab-user/.conda/envs/studiolab/bin/python3.9 -m pip install ipyvuetify ipyvue bqplot ipyvolume ipywebrtc ipyleaflet
After that, ipyleaflet worked for me
SageMaker Studio Lab still does not work for me.
Here are the steps I used to fix the issue on the normal SageMaker. It works like a charm.
import solara
# a bug in solara, so we monkey patch it
solara._using_solara_server = lambda: False
libraries_extra = [ {"python": "bqplot", "classic": "bqplot/extension", "lab": "bqplot"}, {"python": "ipyvolume", "classic": "ipyvolume/extension", "lab": "ipyvolume"}, {"python": "ipywebrtc", "classic": "jupyter-webrtc", "lab": "jupyter-webrtc"}, {"python": "ipyleaflet", "classic": "ipyleaflet/extension", "lab": "jupyter-leaflet"}, ]
solara.checks.check_jupyter(silent=False, force=True, extra=True, libraries_extra=libraries_extra)
6. Run the following command to install extensions
```bash
!/home/ec2-user/anaconda3/envs/JupyterSystemEnv/bin/python3.10 -m pip install ipyvuetify ipyvue bqplot ipyvolume ipywebrtc ipyleaflet anywidget
import solara
# a bug in solara, so we monkey patch it
solara._using_solara_server = lambda: False
libraries_extra = [ {"python": "bqplot", "classic": "bqplot/extension", "lab": "bqplot"}, {"python": "ipyvolume", "classic": "ipyvolume/extension", "lab": "ipyvolume"}, {"python": "ipywebrtc", "classic": "jupyter-webrtc", "lab": "jupyter-webrtc"}, {"python": "ipyleaflet", "classic": "ipyleaflet/extension", "lab": "jupyter-leaflet"}, ]
solara.checks.check_jupyter(silent=False, force=True, extra=True, libraries_extra=libraries_extra)
8. Try leafmap with ipyleaflet
```python
import leafmap
leafmap.Map()
import leafmap.maplibregl as leafmap
leafmap.Map()
I did the same thing early this week and got it works. The step #6 and #7 are the keys.
Here are the steps I used to fix the issue on the normal SageMaker. It works like a charm.
- Create a new notebook instance and select the appropriate hardware (e.g., ml.t3.medium)
- Open the terminal
- Install packages: mamba install -c conda-forge leafmap solara
- Create a new notebook using the Python 3 (ipykernel)
- Run this code below below. It may show that the extensions are NOT installed at the server
import solara # a bug in solara, so we monkey patch it solara._using_solara_server = lambda: False # pass in updated module names (next release of solara we should also fix this) libraries_extra = [ {"python": "bqplot", "classic": "bqplot/extension", "lab": "bqplot"}, {"python": "ipyvolume", "classic": "ipyvolume/extension", "lab": "ipyvolume"}, {"python": "ipywebrtc", "classic": "jupyter-webrtc", "lab": "jupyter-webrtc"}, {"python": "ipyleaflet", "classic": "ipyleaflet/extension", "lab": "jupyter-leaflet"}, ] solara.checks.check_jupyter(silent=False, force=True, extra=True, libraries_extra=libraries_extra)
- Run the following command to install extensions
!/home/ec2-user/anaconda3/envs/JupyterSystemEnv/bin/python3.10 -m pip install ipyvuetify ipyvue bqplot ipyvolume ipywebrtc ipyleaflet anywidget
- Restart the kernel and refresh the browser page. Then run the following code block again. It should now show that the extensions have been installed at the server
import solara # a bug in solara, so we monkey patch it solara._using_solara_server = lambda: False # pass in updated module names (next release of solara we should also fix this) libraries_extra = [ {"python": "bqplot", "classic": "bqplot/extension", "lab": "bqplot"}, {"python": "ipyvolume", "classic": "ipyvolume/extension", "lab": "ipyvolume"}, {"python": "ipywebrtc", "classic": "jupyter-webrtc", "lab": "jupyter-webrtc"}, {"python": "ipyleaflet", "classic": "ipyleaflet/extension", "lab": "jupyter-leaflet"}, ] solara.checks.check_jupyter(silent=False, force=True, extra=True, libraries_extra=libraries_extra)
- Try leafmap with ipyleaflet
import leafmap leafmap.Map()
- Try leafmap with maplibre
import leafmap.maplibregl as leafmap leafmap.Map()
Has anyone ever used ipyleaflet with Amazon SageMaker Studio Lab? I can't get it to work.