Loading ROM doesn't work with library

I installed 2.4.1 on my laptop, attempting to load metroid2 with the pyboy binary works fine, but when attempting to load the same ROM in a python file fails:
from pyboy import PyBoy

pyboy = PyBoy("metroid2.gb")
while True:
pyboy.tick(render=True)
from pyboy import PyBoy

pyboy = PyBoy("metroid2.gb")
while True:
pyboy.tick(render=True)
I get this error:
File "pyboy/pyboy.py", line 139, in pyboy.pyboy.PyBoy.__init__
File "pyboy/core/mb.py", line 36, in pyboy.core.mb.Motherboard.__init__
File "pyboy/core/cartridge/cartridge.py", line 20, in pyboy.core.cartridge.cartridge.load_cartridge
File "pyboy/core/cartridge/cartridge.py", line 21, in pyboy.core.cartridge.cartridge.load_cartridge
File "pyboy/core/cartridge/cartridge.py", line 62, in pyboy.core.cartridge.cartridge.load_romfile
Exception: Bad ROM file size
File "pyboy/pyboy.py", line 139, in pyboy.pyboy.PyBoy.__init__
File "pyboy/core/mb.py", line 36, in pyboy.core.mb.Motherboard.__init__
File "pyboy/core/cartridge/cartridge.py", line 20, in pyboy.core.cartridge.cartridge.load_cartridge
File "pyboy/core/cartridge/cartridge.py", line 21, in pyboy.core.cartridge.cartridge.load_cartridge
File "pyboy/core/cartridge/cartridge.py", line 62, in pyboy.core.cartridge.cartridge.load_romfile
Exception: Bad ROM file size
Really strange since I can load SML fine
5 Replies
Bækalfen
Bækalfen6mo ago
And you're certain this is a Game Boy ROM? Does it work in other emulators? That check is just a validation that we have data enough in the file to fill the expected ROM banks. Could be that some ROM dumper is truncating or something
capnspacehook
capnspacehookOP6mo ago
Yeah it works with sameboy and works when I use the pyboy binary from the command line. Very strange
Bækalfen
Bækalfen6mo ago
It works from the command line? That is strange. Could you paste that example? I guess I'm at fault, that PyBoy doesn't report it's own version on start-up or on the command line, but do you know if you're using two different versions?
capnspacehook
capnspacehookOP6mo ago
I'm pretty sure they aren't, as I was running the above script and pyboy from the command line in the same terminal instance in the same virtualenv
Bækalfen
Bækalfen6mo ago
If you do ls -la metroid2.gb how large is the file then?

Did you find this page helpful?