AttributeError: ‘dict’ object has no attribute ‘iteritems’ – Python

Hey everyone,

Just running through object detection samples for Tensorflow and I encountered the following error:

Sample: https://github.com/GoogleCloudPlatform/tensorflow-object-detection-example

AttributeError: ‘dict’ object has no attribute ‘iteritems’

The issue seems to be that the sample hasn’t been made compatible with Python 3.x. Simply make the following change and it should work:


# Original
for cls, new_image in new_images.iteritems():

# Changed
for cls, new_image in new_images.items():

Thanks to the following StackOverflow post: https://stackoverflow.com/a/30418498/522859

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.