python-console-snake
python-console-snake copied to clipboard
AttributeError: 'dict' object has no attribute 'iteritems'
After running
git clone [email protected]:tancredi/python-console-snake.git
cd python-console-snake
python snake
I got:
Traceback (most recent call last):
File "/usr/lib/python3.4/runpy.py", line 170, in _run_module_as_main
"__main__", mod_spec)
File "/usr/lib/python3.4/runpy.py", line 85, in _run_code
exec(code, run_globals)
File "snake/__main__.py", line 26, in <module>
run()
File "snake/__main__.py", line 19, in run
theme.init()
File "snake/theme.py", line 14, in init
colors_map = get_colors_map()
File "snake/theme.py", line 30, in get_colors_map
for col in theme['colors'].iteritems():
AttributeError: 'dict' object has no attribute 'iteritems'
%
Yes, with all that whitespace in between.
Check https://github.com/tancredi/python-console-snake/issues/5 - It needs to run on a maximised window - Will have to fix that eventually
Not applicable. Different results, different stacktrace, and I'm not on OS X. I'm also using a tiling window manager, so the concept of "maximization" is inexistant.
Oh, I see - sorry - What OS are you running on?
Some quick googling informed showed that iteritems()
should read items()
. I changed that, but I'm now getting:
Traceback (most recent call last):
File "/usr/lib/python3.4/runpy.py", line 170, in _run_module_as_main
"__main__", mod_spec)
File "/usr/lib/python3.4/runpy.py", line 85, in _run_code
exec(code, run_globals)
File "snake/__main__.py", line 26, in <module>
run()
File "snake/__main__.py", line 21, in run
gameloop.start()
File "snake/gameloop.py", line 45, in start
init()
File "snake/gameloop.py", line 64, in init
graphics.drawGame()
File "snake/graphics.py", line 85, in drawGame
drawTile(x, y, theme.get_tile('bg'), theme.get_color('bg'))
File "snake/graphics.py", line 16, in drawTile
screen.addstr(y, x, tile, color)
TypeError: integer argument expected, got float
%
Oh, I see - sorry - What OS are you running on?
$ uname -a
Linux athena.barrera.io 4.0.4-1-ARCH #1 SMP PREEMPT Mon May 18 06:43:19 CEST 2015 x86_64 GNU/Linux
Try using virtual console, it has worked for me with ubuntu. Ctrl-Alt-F1 and login with your account.
Same result. I fail how using a virtual console would affect TypeError: integer argument expected, got float
though.
@hobarrera This looks much like a Python 2 <-> Python 3 incompatibility (iteritems
vs. items
, float result of a division instead of integer; see the changes proposed with PR #7). Run snake with Python 2 and it will almost certainly work.
I also get this problem.
The error in this issue is because the code was expecting an [at the time] older version of Python (Python 2).
~~This was in 2015 though, I doubt you're getting the same error. Python 2 is completely dead now.~~
Never mind, this hasn't been updated in 5 years. You're gonna have to install python2 (it can coexist with a current Python) to run this project.