I am not sure this is a bug or some of my misunderstanding. If the first case applies, please let me know so I will use the appropriate issue tracker.
Consider the following ./myscript.py :
import numpy as np
import matplotlib.pyplot as plt
tf = 20
f0 = 1
fs = 4*np.pi*f0
t = np.arange(0, tf, 1/fs)
fig, ax = plt.subplots()
ax.plot(t, np.sin(2*np.pi*f0*t))
plt.show()
If I run the above script through a jupyter console through the following command:
In [1]: run -i ./myscript.py
then the console freezes and I have to <c-c> and then restart the kernel to be able to continue to work.
If I modify the above script by removing the last line and I run the following:
In [1]: run -i ./myscript.py
In [2]: plt.show()
then things work perfectly, but it is very annoying to manually call plt.show() as shown in the latter example.
How to solve the problem?
EDIT: More details. After I stopped the kernel with <c-c> and I try to run any command from jupyter console, I get the following error message:
/opt/homebrew/Caskroom/miniconda/base/envs/manim_ce/lib/python3.11/site-packages/jupyter_console/ptshell.py:787: UserWarning: The kernel did
not respond to an is_complete_request. Setting `use_kernel_is_complete` to False.
warn('The kernel did not respond to an is_complete_request. '
[SOLVED]: I had to add a
plt.pause()before plotting. The above script has been modified as: