# IPython not defined from Javascript

**URL:** <https://discourse.jupyter.org/t/ipython-not-defined-from-javascript/28004>\
**Category:** JupyterLab\
**Tags:** jupyterlab, help-wanted\
**Created:** [August 31, 2024, 1:02pm UTC](https://discourse.jupyter.org/t/ipython-not-defined-from-javascript/28004 "2024-08-31T13:02:41Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![fomightez](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.jupyter.org/fomightez/32/495_2.png) [@fomightez](https://discourse.jupyter.org/u/fomightez)\
**Post date:** [August 31, 2024, 1:52pm UTC](https://discourse.jupyter.org/t/ipython-not-defined-from-javascript/28004/2 "2024-08-31T13:52:12Z")

</div>

> [@YouGuessedMyName](#):
>
> I have seen examples on the internet of people using IPython within Javascript to do this sort of communication.

Hopefully, you have seen that the Jupyter ecosystem has changed a lot in the last year or so. If not , go [here](https://stackoverflow.com/a/76837597/8508004) and look at the bottom half of my reply there. What you are asking about pertains to Jupyter Notebook 7+ and JupyterLab being on JupyterLab components. Most of the posts you find on the internet pertain to older versions of Jupyter.

This example you first invoke using `IPython.notebook.kernel.execute()` is indeed one of the things that has changed. This is has been covered here on this forum already [here](https://discourse.jupyter.org/t/executing-java-script-code-in-jupyterlab-gives-error/14894/2) and [here](https://discourse.jupyter.org/t/how-to-execute-cell-in-jupyterlab-javascript-jupyter-notebook-execute-cells-not-working/22993/5).

See also:

- [Example snippet related to Javascript and use of `jupyterapp c.LabApp.expose_app_in_browser`](https://discourse.jupyter.org/t/run-python-code-from-javascript-jupyterlab/24627)
- There is `kernel.execute_code()`, see [here](https://discourse.jupyter.org/t/better-way-to-communicate-from-kernel-from-to-jupyterlab-extension-than-prints/18100)
- [example snippet using `ipylab` to run code](https://stackoverflow.com/a/71944193/8508004) (I link to some other `ipylab`-related snippets [here](https://stackoverflow.com/questions/77925607/how-to-run-the-specific-cells-below-or-above-in-jupyter-lab#comment137382206_77925607) and [here](https://stackoverflow.com/a/69011143/8508004))
- [Running Javascript from a notebook in JupyterLab](https://gist.github.com/gnestor/f1893e0226ced227e910f11b769adc06) and another example [here](https://discourse.jupyter.org/t/download-widget/18758/4)
- My comments below a question about keeping an interactive SVG interactive in JupyterLab v4+ and Jupyter Notebook 7+, that [mention](https://stackoverflow.com/questions/77902970/how-can-i-display-an-interactive-svg-image-that-utilizes-javascript-in-a-jupyter?noredirect=1#comment137349169_77902970) use of `%load_ext ipyreact` that worked in those versions of the current Jupyter tech to display confetti over the browser page using code inside Jupyter.
- Basic tests of Javascript working in modern Jupyter are possible using the `console.log` and `alert` systems, see more about that with example code [here](https://github.com/jupyter-widgets/ipywidgets/issues/2458#issuecomment-506248439), [here](https://discourse.jupyter.org/t/method-to-access-query-string-in-voila-notebook/5387/6), and [here](https://stackoverflow.com/a/78953699/8508004).

---

_[View the full topic](https://discourse.jupyter.org/t/ipython-not-defined-from-javascript/28004)._
