openai / retro

Retro Games in Gym
MIT License
3.35k stars 524 forks source link

UnboundLocalError: local variable 'ext' referenced before assignment #260

Open ll7 opened 2 years ago

ll7 commented 2 years ago

Issue summary

I am trying to install a rom and I get the following error:

roms$ python -m retro.import .
Traceback (most recent call last):
  File "/home/luttkule/anaconda3/envs/rl-test/lib/python3.9/runpy.py", line 197, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/home/luttkule/anaconda3/envs/rl-test/lib/python3.9/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/home/luttkule/anaconda3/envs/rl-test/lib/python3.9/site-packages/retro/import/__main__.py", line 4, in <module>
    main()
  File "/home/luttkule/anaconda3/envs/rl-test/lib/python3.9/site-packages/retro/scripts/import_path.py", line 21, in main
    known_hashes = retro.data.get_known_hashes()
  File "/home/luttkule/anaconda3/envs/rl-test/lib/python3.9/site-packages/retro/data/__init__.py", line 401, in get_known_hashes
    known_hashes[sha] = (game, ext, os.path.join(path(), curpath))
UnboundLocalError: local variable 'ext' referenced before assignment

This is the content of the directory:

roms$ ls
'Street Fighter II'\'' - Special Champion Edition (Europe).md'  'Street Fighter II'\'' - Special Champion Edition (Europe).zip'

I downlaoded and extracted the rom from https://wowroms.com/en/roms/sega-genesis-megadrive/download-street-fighter-ii-special-champion-edition-europe/26496.html

System information

pacess commented 2 years ago

A quick fix for your case, edit /home/luttkule/anaconda3/envs/rl-test/lib/python3.9/site-packages/retro/data/init.py line 401, replace ext with ".md". It should be look like:

known_hashes[sha] = (game, ".md", os.path.join(path(), curpath))

ll7 commented 2 years ago

Thank you.

It seems to me that the import is still not successful:

(rl-test) luttkule@LeLuGPC-u:/mnt/UHDD/git/rl-test/nicholas-renotte/streetfighter/roms$ ls
'Street Fighter II'\'' - Special Champion Edition (Europe).md'  'Street Fighter II'\'' - Special Champion Edition (Europe).zip'
(rl-test) luttkule@LeLuGPC-u:/mnt/UHDD/git/rl-test/nicholas-renotte/streetfighter/roms$ python -m retro.import .
Imported 0 games
(rl-test) luttkule@LeLuGPC-u:/mnt/UHDD/git/rl-test/nicholas-renotte/streetfighter/roms$ python -m retro.import 'Street Fighter II'\'' - Special Champion Edition (Europe).md'
Imported 0 games
(rl-test) luttkule@LeLuGPC-u:/mnt/UHDD/git/rl-test/nicholas-renotte/streetfighter/roms$ python -m retro.import .
Imported 0 games
(rl-test) luttkule@LeLuGPC-u:/mnt/UHDD/git/rl-test/nicholas-renotte/streetfighter/roms$ python -m retro.import Street\ Fighter\ II\'\ -\ Special\ Champion\ Edition\ \(Europe\).md
Imported 0 games
onaclov2000 commented 1 year ago

I'm not 100% sure but did you make sure your rom.sha matches the file you downloaded? If not you might need to update/create a rom.sha file.