TypeError cannot unpack non-iterable NoneType object

0 votes
from cv2 import cv2
import numpy as np
import pyzbar.pyzbar as pyzbar
import base64
import time
import datetime
import xlwt 
from xlwt import Workbook

cap = cv2.VideoCapture(0)
font = cv2.FONT_HERSHEY_PLAIN

fob=open('attendence.txt','w+')

names=[]
def enterData(z):
    if z in names:
        pass
    else:
        names.append(z)
        z=''.join(str(z))
        fob.write(z+'\n')
    return names

print('Reading...')
def checkData(data):
    try:
        data=str(base64.b64decode(data).decode())
    except(TypeError):
        print('Invalid ID !!!')
        return
    if data in names:
        print('Already Present')
    else:
        print('\n'+str(len(names)+1)+'\n'+data)
        enterData(data)
    cv2.putText(frame, str(base64.b64decode(obj.data)), (50, 50), font, 2,
                (255, 0, 0), 3)
    
while True:
    _,frame = cap.read()
 
    decodedObjects = pyzbar.decode(frame)
    for obj in decodedObjects:
        checkData(obj.data)
        #print("Data", base64.b64decode(obj.data))
        #enterData(base64.b64decode(obj.data))
        #print(len(names))
        #sys.stdout.write('\r'+'Reading...'+str(len(names))+'\t'+str(base64.b64decode(obj.data)))
        #sys.stdout.flush()
        time.sleep(1)
       
    cv2.imshow("Frame", frame)

    if cv2.waitKey(1)& 0xFF == ord('s'):
        cv2.destroyAllWindows()
        break
    
fob.close()

d_date = datetime.datetime.now()
reg_format_date = d_date.strftime("%d-%m-%Y %I:%M:%S %p")
reg_format_date=reg_format_date.replace(':',' ')

def writeExcel(names,reg_format_date):

    wb = Workbook()
    
    sheet1 = wb.add_sheet('Sheet 1')
    for i in range(0,len(names)):
        sheet1.write(i, 1, names[i]) 

    wb.save(reg_format_date+'.xls')
writeExcel(names,reg_format_date)

Oct 2, 2020 in Python by anonymous
• 120 points

edited Oct 4, 2020 by Gitika 79,364 views

1 answer to this question.

0 votes

Hello,

The “TypeError: cannot unpack non-iterable NoneType object” error is raised when you try to unpack values from one that is equal to None.

A common cause of this error is when you try to unpack values from a function that does not return a value. To solve this error, make sure the value you are trying to unpack is a sequence, such as a list or a tuple.

answered Oct 5, 2020 by Lisa

Related Questions In Python

0 votes
0 answers

TypeError: 'NoneType' object is not iterable in Python

What does this error mean?  I get this ...READ MORE

May 5, 2022 in Python by Kichu
• 19,050 points
1,279 views
0 votes
1 answer
0 votes
2 answers

TypeError: 'float' object cannot be interpreted as an integer

Hi@akhtar, The range function does not work with ...READ MORE

answered Jun 29, 2020 in Python by MD
• 95,440 points
16,356 views
0 votes
1 answer

TypeError: 'float' object cannot be interpreted as an integer

Hi, @There, The “TypeError: ‘float’ object cannot be ...READ MORE

answered Nov 13, 2020 in Python by Gitika
• 65,910 points
41,468 views
0 votes
0 answers

Python - TypeError: 'int' object is not iterable

Here's my code: import math print("Hey, lets solve Task ...READ MORE

Dec 21, 2022 in Python by erzan
• 630 points
576 views
0 votes
1 answer

Python Math - TypeError: 'NoneType' object is not subscriptable

“TypeError: 'NoneType' object is not subscriptable” is ...READ MORE

answered Jan 4, 2023 in Python by Elton
• 400 points
771 views
0 votes
2 answers
+1 vote
2 answers

how can i count the items in a list?

Syntax :            list. count(value) Code: colors = ['red', 'green', ...READ MORE

answered Jul 7, 2019 in Python by Neha
• 330 points

edited Jul 8, 2019 by Kalgi 4,069 views
0 votes
1 answer
+5 votes
6 answers

Lowercase in Python

You can simply the built-in function in ...READ MORE

answered Apr 11, 2018 in Python by hemant
• 5,790 points
3,488 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP