title: AttributeError: 'NoneType' object has no attribute 'shape' What is wrong in my code?
body: <p>I got an error,AttributeError: 'NoneType' object has no attribute 'shape'.I wrote codes in views.py</p>
  
  <pre><code>import os
  import cv2
  from pathlib import Path
  import random
  
  path = Path(__file__).parent
  path /= "../../image1"
  
  path1 = Path(__file__).parent
  path1 /= "../../image2"
  
  index_list =[]
  for i in path.iterdir():
    i = str(i)
    print(i)
    if i.split(".")[-1].lower() in {"jpeg", "jpg", "png"}:
        list_img = cv2.imread(i)
        index_list.append(list_img)
  
  num = 0
  for j in path.iterdir():
    j = str(j)
    if j.split(".")[-1].lower() in {"jpeg", "jpg", "png"}:
          img = cv2.imread(j)
          num += 1
  
          random_int = random.randint(0, 9)
          index = index_list[random_int]
          height1 = index.shape[0]
          width1 = index.shape[1]
          print(height1)
          print(width1)
  </code></pre>
  
  <p>When I run this code,I got an error,    height1 = index.shape[0]
  AttributeError: 'NoneType' object has no attribute 'shape'  .
  In image1's folder,5 images are in there like photo1,photo2,photo3,photo4,photo5.I debuted this program,so I found photo3 causes this error,and I deleted photo3 from image1's folder.And I run this program again,photo2 causes this error.I really cannot understand why this error happens.I think maybe wrong path of the folder causes this error,but it is wrong.How should I fix this?What is wrong in my code?</p>