ipyvega icon indicating copy to clipboard operation
ipyvega copied to clipboard

404 error when rendering

Open ABeltramo opened this issue 3 years ago • 5 comments

I'm getting a 404 error in the browser (and in the jupyter console) when running the Vega(...) cell.

Here's the output from the jupyter console

404 GET /static/jupyter-vega.js (127.0.0.1) 6.740000ms referer=http://localhost:8889/notebooks/src/sdk/Untitled.ipynb?kernel_name=python3

Here's the output in the browser:

Loading failed for the <script> with source “http://localhost:8889/static/jupyter-vega.js”.

I followed the installation instruction on the README, here is my current venv:

Python 3.8.2 Jupyter Notebook 6.4.11 vega 3.6.0

pip freeze:

anyio==3.5.0
appnope==0.1.2
argon2-cffi==21.3.0
argon2-cffi-bindings==21.2.0
asgiref==3.5.0
asttokens==2.0.5
attrs==21.4.0
backcall==0.2.0
beniget==0.4.1
black==22.1.0
bleach==4.1.0
certifi==2021.10.8
cffi==1.15.0
chardet==4.0.0
click==8.0.3
cycler==0.11.0
Cython==0.29.27
debugpy==1.5.1
decorator==5.1.1
defusedxml==0.7.1
entrypoints==0.4
executing==0.8.2
fastapi==0.75.2
Flask==2.0.2
fonttools==4.29.1
gast==0.5.3
h11==0.13.0
httptools==0.4.0
idna==2.10
importlib-resources==5.4.0
ipykernel==6.9.0
ipython==8.0.1
ipython-genutils==0.2.0
ipywidgets==7.6.5
itsdangerous==2.0.1
jedi==0.18.1
Jinja2==3.0.3
joblib==1.1.0
jsonschema==4.4.0
jupyter==1.0.0
jupyter-client==7.1.2
jupyter-console==6.4.0
jupyter-core==4.9.1
jupyterlab-pygments==0.1.2
jupyterlab-widgets==1.0.2
kiwisolver==1.3.2
MarkupSafe==2.0.1
matplotlib==3.5.1
matplotlib-inline==0.1.3
mistune==0.8.4
msgpack-python==0.5.6
mypy-extensions==0.4.3
nbclient==0.5.10
nbconvert==6.4.2
nbformat==5.1.3
nest-asyncio==1.5.4
notebook==6.4.11
numpy==1.22.2
opencv-python==4.5.5.64
packaging==21.3
pandas==1.4.0
pandocfilters==1.5.0
parameters-validation==1.2.0
parso==0.8.3
pathspec==0.9.0
pexpect==4.8.0
pickleshare==0.7.5
Pillow==9.0.1
platformdirs==2.5.0
ply==3.11
prometheus-client==0.13.1
prompt-toolkit==3.0.27
ptyprocess==0.7.0
pure-eval==0.2.2
pybind11==2.9.1
pycparser==2.21
pydantic==1.9.0
Pygments==2.11.2
pyparsing==3.0.7
pyrsistent==0.18.1
python-dateutil==2.8.2
python-dotenv==0.20.0
pythran==0.11.0
pytz==2021.3
PyYAML==6.0
pyzmq==22.3.0
qtconsole==5.2.2
QtPy==2.0.1
requests==2.25.1
scipy==1.9.0.dev0+1091.e569c7a
seaborn==0.11.2
Send2Trash==1.8.0
six==1.16.0
sniffio==1.2.0
sseclient-py==1.7.2
stack-data==0.1.4
starlette==0.17.1
terminado==0.13.1
testpath==0.5.0
tomli==2.0.1
tornado==6.1
tqdm==4.64.0
traitlets==5.1.1
transit-python==0.8.302
typing_extensions==4.0.1
urllib3==1.26.8
uvicorn==0.17.6
uvloop==0.16.0
vega==3.6.0
Wand==0.6.7
watchgod==0.8.2
wcwidth==0.2.5
webencodings==0.5.1
websockets==10.3
Werkzeug==2.0.3
widgetsnbextension==3.5.2
zipp==3.7.0

ABeltramo avatar May 13 '22 08:05 ABeltramo

Downgrade to 3.5 works

PaleNeutron avatar Jun 24 '22 01:06 PaleNeutron

Same here -- I think this issue is related to https://github.com/vega/ipyvega/commit/5acd121ca9441270653984984b22dd713f857cb6. Specifically, this 404 comes from trying to require "jupyter-vega" without configuring it.

I don't understand all the internals of how the nbextension gets loaded, but I do know that running jupyter nbextension enable vega --py --sys-prefix activates jupyter-vega/index, NOT jupyter-vega/extension. And, if I manually edit the notebook.json file to say jupyter-vega/extension, it still doesn't work, because index.js executes before extension.js does.

zmbc avatar Jul 25 '22 22:07 zmbc

Furthermore, this extension appears to have depended on the execution order/timing even before 3.6. Specifically, the check for an already-rendered static image only works if the JS execution happens right away (before an image, later in the outputs array, is rendered). When the require call does not return immediately, because the extension has not been loaded yet, the end result is that the extension preferentially shows the PNG output instead of the interactive output.

Edit: I cannot seem to get this extension to do what I want (render the interactive version if possible, fall back to the PNG version where that isn't possible) no matter what versions I use -- the extension has had this logic from the time PNG rendering was introduced and Jupyter notebooks have been loading extensions asynchronously for a very long time. Could this possibly be the intended behavior? I find that extremely surprising.

zmbc avatar Jul 26 '22 00:07 zmbc

Downgrade to 3.5 works

Confirmed downgrading fixes the issue (no plot showing in the cell output, no errors in the notebook) for me as well.

giuliano108 avatar Nov 11 '22 17:11 giuliano108

@cpsievert I am running into this issue as well. Can you help fix it?

domoritz avatar Feb 12 '23 16:02 domoritz