Skip to content
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

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

Open
WhyNotHugo opened this issue May 19, 2015 · 9 comments
Open

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

WhyNotHugo opened this issue May 19, 2015 · 9 comments

Comments

@WhyNotHugo
Copy link

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.

@tancredi
Copy link
Owner

Check #5 - It needs to run on a maximised window - Will have to fix that eventually

@WhyNotHugo
Copy link
Author

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.

@tancredi
Copy link
Owner

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

@WhyNotHugo
Copy link
Author

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

@mdimec4
Copy link

mdimec4 commented May 19, 2015

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

@WhyNotHugo
Copy link
Author

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

@bittner
Copy link

bittner commented Aug 20, 2016

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

@guyuedumingx
Copy link

I also get this problem.

@WhyNotHugo
Copy link
Author

WhyNotHugo commented Jun 15, 2020

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants