There is a new p5 library in pyPI that can be installed in Google Colaboratory:
!pip install -U p5
import p5
However, I have had problems getting the chart to show. It seems to be a problem with glfw - getting it to send the graphics to the right display. I am using this on Win10. Readthedocs with installation instructions for p5 is here.
The following example is taken from the p5 repository - https://github.com/p5py/p5
def setup():
p5.size(640, 360)
p5.no_stroke()
p5.background(204)
def draw():
if p5.mouse_is_pressed:
p5.fill(p5.random_uniform(255), p5.random_uniform(127), p5.random_uniform(51), 127)
else:
p5.fill(255, 15)
circle_size = p5.random_uniform(low=10, high=80)
p5.circle((p5.mouse_x, p5.mouse_y), circle_size)
def key_pressed(event):
p5.background(204)
p5.run()
The error messages are:
---------------------------------------------------------------------------
OSError Traceback (most recent call last)
<ipython-input-7-2146d31dac46> in <module>()
20 p5.background(204)
21
---> 22 p5.run()
5 frames
/usr/local/lib/python3.7/dist-packages/vispy/app/backends/_glfw.py in _vispy_get_native_app(self)
213 try:
214 if not glfw.glfwInit(): # only ever call once
--> 215 raise OSError('Could not init glfw:\n%r' % _glfw_errors)
216 finally:
217 os.chdir(cwd)
OSError: Could not init glfw:
["Error 65544: b'X11: The DISPLAY environment variable is missing'"]