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

Ipyvolume cannot be imported in Jupyterlite: KeyError: 'emscripten' #427

Closed
MarcSkovMadsen opened this issue Feb 5, 2023 · 3 comments · Fixed by #429
Closed

Ipyvolume cannot be imported in Jupyterlite: KeyError: 'emscripten' #427

MarcSkovMadsen opened this issue Feb 5, 2023 · 3 comments · Fixed by #429

Comments

@MarcSkovMadsen
Copy link

Reproduce

import piplite
await piplite.install('ipyvolume')
  • run a cell containing
import ipyvolume

image

---------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)
Cell In[2], line 1
----> 1 import ipyvolume

File /lib/python3.10/site-packages/ipyvolume/__init__.py:6
      4 from ipyvolume import styles  # noqa: F401
      5 from ipyvolume import examples  # noqa: F401
----> 6 from ipyvolume import datasets  # noqa: F401
      7 from ipyvolume import embed  # noqa: F401
      8 from ipyvolume.widgets import *  # noqa: F401, F403

File /lib/python3.10/site-packages/ipyvolume/datasets.py:13
      9     from urllib.request import urlretrieve  # py3
     11 import numpy as np
---> 13 osname = dict(darwin="osx", linux="linux", windows="windows")[platform.system().lower()]
     14 data_dir = os.path.expanduser("~/.ipyvolume/datasets")
     15 if not os.path.exists(data_dir):

KeyError: 'emscripten'

Context

I am trying to improve the user experience of running Panel in its custom build of Jupyterlite called Panelite in Panel #4388.

Now I am working with the notebook reference/panes/IPyWidget.ipynb which needs to import ipyvolume. But it fails.

@scrgiorgio
Copy link

@MarcSkovMadsen

don't know if it helps. But this is what I am doing in JupyterLite:

# cell 1
%pip install -q ipywidgets plotly ipyvolume ipython_genutils

# cell 2
def PatchIPyVolume(filename="/lib/python3.10/site-packages/ipyvolume/datasets.py"):
    # osname = dict(darwin="osx", linux="linux", windows="windows")[platform.system().lower()]
    with open(filename,"r") as f: lines=f.readlines()
    lines=["osname = platform.system().lower()\n" if line.startswith("osname =") else line for line in lines]
    with open(filename,"w") as f: f.writelines(lines)
PatchIPyVolume()

# cell3
import ipyvolume as ipv

@maartenbreddels
Copy link
Collaborator

This should be fixed in 0.6.1, thanks for reporting Marc!

Nice patch @scrgiorgio

@MarcSkovMadsen
Copy link
Author

Thx all.

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

Successfully merging a pull request may close this issue.

3 participants