python-console-snake icon indicating copy to clipboard operation
python-console-snake copied to clipboard

AttributeError: 'dict' object has no attribute 'iteritems'

Open WhyNotHugo opened this issue 9 years ago • 9 comments

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.

WhyNotHugo avatar May 19 '15 18:05 WhyNotHugo

Check https://github.com/tancredi/python-console-snake/issues/5 - It needs to run on a maximised window - Will have to fix that eventually

tancredi avatar May 19 '15 18:05 tancredi

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.

WhyNotHugo avatar May 19 '15 19:05 WhyNotHugo

Oh, I see - sorry - What OS are you running on?

tancredi avatar May 19 '15 19:05 tancredi

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

WhyNotHugo avatar May 19 '15 19:05 WhyNotHugo

Try using virtual console, it has worked for me with ubuntu. Ctrl-Alt-F1 and login with your account.

mdimec4 avatar May 19 '15 19:05 mdimec4

Same result. I fail how using a virtual console would affect TypeError: integer argument expected, got float though.

WhyNotHugo avatar May 19 '15 21:05 WhyNotHugo

@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.

bittner avatar Aug 20 '16 19:08 bittner

I also get this problem.

guyuedumingx avatar Jun 15 '20 13:06 guyuedumingx

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.

WhyNotHugo avatar Jun 15 '20 14:06 WhyNotHugo