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 in Python by anonymous
• 120 points

edited Oct 4 by Gitika 2,491 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 by Lisa

Related Questions In Python

0 votes
1 answer
0 votes
1 answer

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

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

answered Jun 29 in Python by MD
• 78,910 points
4,858 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 in Python by Gitika
• 49,300 points
58 views
0 votes
1 answer

Python inheritance: TypeError: object.__init__() takes no parameters

You are calling the wrong class name ...READ MORE

answered Nov 15, 2018 in Python by Nymeria
• 3,520 points
2,067 views
0 votes
1 answer

print(instance(0).id) TypeError: 'list' object is not callable

Hey @Suraj, For me its working fine. ...READ MORE

answered Jan 18, 2019 in Python by Priyaj
• 57,700 points
827 views
0 votes
1 answer

Python TypeError: 'list' object is not callable.

The error says the list is not ...READ MORE

answered Feb 8, 2019 in Python by Omkar
• 69,030 points
18,630 views
+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 6, 2019 in Python by Neha
• 330 points

edited Jul 8, 2019 by Kalgi 1,560 views
0 votes
0 answers
+4 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,800 points
1,177 views