Closed
Description
Checklist
- I added a descriptive title
- I searched for other issues and couldn't find a solution or duplication
- I already searched in Google and didn't find any good information or help
What happened?
When using <script type="py-game">
, packages specified in the configuration are not being installed/loaded properly, despite working correctly with <script type="py">
. This appears to affect all non-standard library packages when using the PyGame integration.
What browsers are you seeing the problem on? (if applicable)
Firefox
Console info
ModuleNotFoundError: No module named 'numpy'
The module 'numpy' is included in the Pyodide distribution, but it is not installed.
You can install it by calling:
await micropip.install("numpy") in Python, or
await pyodide.loadPackage("numpy") in JavaScript
Additional Context
What Works / What Doesn't
- ✅ Standard library packages work fine with both script types
- ✅ External packages work correctly when using
<script type="py">
- ❌ External packages fail to load when using
<script type="py-game">
- ❌ The issue occurs with any external package (numpy, httpx, etc.)
Steps to Reproduce
- Create a simple HTML file with a PyGame script that imports an external package
- Configure the package in TOML:
packages = ["numpy"]
- Use
<script type="py-game" src="main.py" config="pyscript.toml"></script>
- Observe the error when trying to import the package
Minimal Reproducible Example
I've created a minimal example to demonstrate this issue: https://pyscript.com/@dyeaw/pygame-numpy-minimal-example/
Expected Behavior
Packages specified in the configuration should be properly installed and available for import when using type="py-game"
, just as they are with type="py"
.
Additional Information
- PyScript Version: 2025.2.4
- It can be reproduced in the latest Firefox and Chrome
I understand that PyGame support is experimental, but this issue makes it difficult to build applications that integrate PyGame with other packages.