pygame-web / pygbag

python and pygame wasm for everyone ( packager + test server + simulator )
https://github.com/pygame-web
MIT License
319 stars 36 forks source link

Numpy dependent modules don't work, even with numpy imported: surfarray, sndarray #86

Closed FinFetChannel closed 1 year ago

FinFetChannel commented 1 year ago

Cannot use pygame modules that depend on numpy, like surfarray and sndarray.

Example:

import numpy
import pygame

new_surf = pygame.surfarray.make_surface(numpy.random.randint(0, 255, (100, 100, 3)))

Results in:

<console>:4: RuntimeWarning: use surfarray: No module named 'numpy'
(ModuleNotFoundError: No module named 'numpy')
Traceback (most recent call last):
  File "/data/data/org.python/assets/site-packages/pygame/__init__.py", line 70, in __getattr__
    raise NotImplementedError(missing_msg)
NotImplementedError: surfarray module not available (ModuleNotFoundError: No module named 'numpy')
pmp-p commented 1 year ago

try

import numpy
import pygame
import pygame.surfarray
print( pygame.surfarray.make_surface(numpy.random.randint(0, 255, (100, 100, 3))) )

test on git version

FinFetChannel commented 1 year ago

It worked! Amazing, thanks!