0

When I place a notebook made in jupyter notebook in a jupyter lab, the following message appears: Javascript Error: IPython is not defined. I installed the jupyter lab just as the page says for windows 10 , ....... what's going on ? Here example of the code, this is what happens in jupyter lab:

%matplotlib notebook
import itertools
import matplotlib.pyplot as plt
import numpy as np
import matplotlib.animation as animation

def data_gen():
    for cnt in itertools.count():
        t = cnt / 10
        yield t, np.sin(2*np.pi*t) * np.exp(-t/10.)

def init():
    ax.set_ylim(-1.1, 1.1)
    ax.set_xlim(0, 1)
    del xdata[:]
    del ydata[:]
    line.set_data(xdata, ydata)
    return line,

fig, ax = plt.subplots()
line, = ax.plot([], [], lw=2)
ax.grid()
xdata, ydata = [], []

def run(data):
    t, y = data
    xdata.append(t)
    ydata.append(y)
    xmin, xmax = ax.get_xlim()

    if t >= xmax:
        ax.set_xlim(xmin, 2*xmax)
        ax.figure.canvas.draw()
    line.set_data(xdata, ydata)

    return line,

ani = animation.FuncAnimation(fig, run, data_gen, interval=100, init_func=init,
                              save_count=100)
plt.show()
Javascript Error: IPython is not defined
C:\Users\marc_arias\AppData\Local\Programs\Python\Python311\Lib\site-packages\matplotlib\animation.py:879: UserWarning: Animation was deleted without rendering anything. This is most likely not intended. To prevent deletion, assign the Animation to a variable, e.g. `anim`, that exists until you output the Animation using `plt.show()` or `anim.save()`.
  warnings.warn(
3
  • How do you expect us to help without showing any code?? Sep 19 at 1:05
  • There's some differences between JupyterLab tech and what used to be possible in older versions of Jupyter Notebook. And so to be sure that is the issue, like John Gordon said, you'd need to tell us at least a toy example that demonstrates this. And current Jupyter Notebook Version 7 is built on JupyterLab tech and so usually in the long run it is worth it to update your approaches.
    – Wayne
    Sep 19 at 3:35
  • Does this answer your question? Javascript Error: IPython is not defined in JupyterLab Sep 20 at 5:21

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Browse other questions tagged or ask your own question.