Skip to main content
edited tags; edited tags
Link
Rabbid76
  • 212.1k
  • 30
  • 163
  • 205

Issue with Pygamepygame-ce in the Jupyter Notebook Demo

Source Link

Issue with Pygame in the Jupyter Notebook Demo

Every time I run any pygame code in Jupyter Notebook (the online demo) it just crashes, giving an error that I've looked for everywhere, to no avail. I'm using the Pyodide Kernel, which apparently supports pygame-ce. However, best I can tell, every time I try to make a screen, it just doesn't recognize where the screen should be.

Here is my code (the pip command is just some testing I was doing to attempt to make it work):

%pip install pygame-ce
import sys
import types
import importlib.machinery
import pygame
from pygame import Color

pygame-ce.init()
screen_width = 640
screen_height = 480
screen = pygame-ce.display.set_mode((screen_width, screen_height))
pygame-ce.display.set_caption("Mixer 1.0")

The error details:

Pyodide has suffered a fatal error. Please report this to the Pyodide maintainers.
The cause of the error was: ReferenceError
screen is not defined
Stack trace:
ReferenceError: screen is not defined
    at _emscripten_get_screen_size (https://cdn.jsdelivr.net/pyodide/v0.27.6/full/pyodide.asm.js:10:524884)
    at wasm://wasm/01ab0eda:wasm-function[1850]:0xcf1ce
    at wasm://wasm/01ab0eda:wasm-function[2749]:0x103b66
    at wasm://wasm/01ab0eda:wasm-function[1353]:0x78456
    at wasm://wasm/01ab0eda:wasm-function[8690]:0x401676
    at https://cdn.jsdelivr.net/pyodide/v0.27.6/full/pyodide.asm.wasm:wasm-function[4590]:0x3288a1
    at https://cdn.jsdelivr.net/pyodide/v0.27.6/full/pyodide.asm.wasm:wasm-function[2189]:0x20c68d
    at https://cdn.jsdelivr.net/pyodide/v0.27.6/full/pyodide.asm.wasm:wasm-function[1172]:0x1c5415
    at https://cdn.jsdelivr.net/pyodide/v0.27.6/full/pyodide.asm.wasm:wasm-function[1171]:0x1c5393
    at wasm://wasm/01ab0eda:wasm-function[8108]:0x3b13f3