def animate(step, p, U):
p_r = np.sqrt(p[0, :]**2 + p[1, :]**2)
u_p = U + (K / (2*np.pi)) * p[0, :] / p_r**2
v_p = (K / (2*np.pi)) * p[1, :] / p_r**2
U = np.asarray([u_p, v_p])
# To avoid very large velocities for particles close to the center
U[:, p_r < r_threshold] = 0.0
# Update positions based on linear advection
p += U * delta_t
points.set_data(p[0, :], p[1, :])
anim = animation.FuncAnimation(fig2, animate, frames=num_timesteps,interval=10000/FPS, fargs=(p, U))
plt.close(anim._fig)
HTML(anim.to_html5_video())
#HTML(anim.to_jshtml())
How can I make this animation run in Pythonista?