-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
pettingzoo #15
Comments
did you try the package yet ? |
Thanks, unzipping the files made those errors go away. Is it possible for pygbag to detect modules if they are in a subdirectory? Unzipping all of the required modules into the same folder as main.py makes it pretty messy. |
@pmp-p I'm having trouble getting numpy to work, I tried a few different versions but keep getting this error Edit: I was able to get past this error by switching to a venv with python 3.11 and doing pip download numpy==1.23.5 and building from there, but now when executing code in another module (pettingzoo) which depends on numpy I get an error saying
|
if modules are in a subfolder "modules" use sys.path.add("modules") before importing them. Do not forget to put all non stdlib imports at top of main.py and in order |
Thanks, will try the system path thing tomorrow. I am importing numpy first then the other two in that order, so I’m not sure what the issue would be. I tried changing the imports to have numpy first in one of the pettingzoo files which is giving the module not found error but that didn’t change anything. Never heard of a single module being imported by one file then somehow not be recognized when used in a different file, but maybe it has to do with asyncio or something. |
The async import of pygbag runtime is a hack, driven by ast module + main.py with no re ordering . Pypi does not provide a deps table, pyodide's one is borrowed but won't cover new modules manually added. |
Makes sense, any idea how to solve the issue if the imports are already in order at the top of main? |
publish repro case somewhere ( without the build folder ) and link it here so we can look into it. |
It turned out to be that the underlying env was calling pygame.surfarray but was only importing pygame, and that was leading to issues. When I explicitly imported pygame.surfarray it worked. |
@pmp-p is it possible to import a local package? I searched through documentation and other issues and didn't find anything. My package is called cathedral-rl and when I run scripts without wasm they work fine, but with wasm it says unknown package cathedral-rl.
|
if module is in a subfolder "modules/cathedral_rl" use sys.path.add("modules") before importing. Otherwise just copy the "cathedral_rl" next to your main.py |
Is it possible to do relative imports of packages which are up in the directory tree? What I’m importing is the entire repo, as I have the main.py file in a subdirectory examples/pygame-wasm/main.py and the game files are in cathedral_rl/. Maybe if I add an init.py file in the directory of main.py and have it import the specific game files? I also tried doing pip download gif+[repo] for the entire repository in that modules subfolder, which isn’t ideal but I figured would work, but that also gave the same error about module not found. Sorry for all the questions, very much appreciate your help and effort developing these tools. |
No, everything upper level of main.py just does not exists in wasm space which is a virtual filesystem. if your package to import is out of tree, make it a wheel or a zip that will be mounted at runtime. or put the main.py where it should be ( with a menu to run tests or examples ) eg https://github.com/pmp-p/nurses_2-wasm/tree/pygbag-port |
Ah I see the problem was that it wasn’t downloading a wheel I think it was just downloading the tree from the repo directly. Will try the wheel approach. If I have main where it admittedly should be in the root directory, will it be able to do relative imports from other subdirectories? The only reason not to put main in root is that it’s a secondary component of my repo which is mainly the implementation of the game, but not a necessarily a problem to have an extra file in the root directory. |
I'm trying to use this package: https://github.com/Farama-Foundation/PettingZoo but I get an error that the package is not found, I think it maybe due to the fact that the module is sometimes capitalized and sometimes lowercase? For example on PyPi it has it listed as
pip install PettingZoo
(https://pypi.org/project/PettingZoo/) but on the repo itself it'spip install pettingzoo
Googling some more though it looks like pip and pypi are case insensitive so this shouldn't matter.Error on http://localhost:8000/#debug:
Edit: looking at viblo/pymunk#213 it looks like it might require python 3.11? Some games in pygame rely on pymunk but the one I am trying to is just pettingzoo, pygame, time, and asyncio
Full script I'm trying to run below:
The text was updated successfully, but these errors were encountered: