title: Image.open PermissionError: [Errno 13] Permission denied:
body: <p>I am making an image classifier to classify rockets and airplanes using Python and TensorFlow, but I'm having trouble loading my training images folder with <code>Pil.Image.Open</code>. This is my code:</p>
  
  <pre><code>train_data = "C:/Users/Will Downs/image_training/training_data/"
  test_data = "C:/Users/Will Downs/image_training/test_data/"
  
  def train_data_with_label():
    train_images = []
    for i in tqdm(os.listdir(train_data)):
      path = os.path.join(train_data, i)
      img = Image.open(path)
      img.thumbnail((64, 64), Image.ANTIALIAS)  # resizes image in-place
      train_images.append([np.array(img), one_hot_label(i)])
    shuffle(train_images)
    return train_images
  
  def test_data_with_label():
    test_images = []
    for i in tqdm(os.listdir(test_data)):
      path = os.path.join(test_data, i)
      img = Image.open(path)
      img.thumbnail((64, 64), Image.ANTIALIAS)  # resizes image in-place
      test_images.append([np.array(img), one_hot_label(i)])
    shuffle(test_images)
    return test_images
  </code></pre>
  
  <p>This is the error I get:</p>
  
  <pre><code>PermissionError                           Traceback (most recent call last)
  &lt;ipython-input-17-f3b44f76f884&gt; in &lt;module&gt;
       46   return test_images
       47 
  ---&gt; 48 training_images = train_data_with_label()
       49 testing_images = test_data_with_label()
       50 tr_img_data = np.array([i[0] for i in training_images]).reshape(-1,64,64,1)
  
  &lt;ipython-input-17-f3b44f76f884&gt; in train_data_with_label()
       30   for i in tqdm(os.listdir(train_data)):
       31     path = os.path.join(train_data, i)
  ---&gt; 32     img = Image.open(path)
       33     img.thumbnail((64, 64), Image.ANTIALIAS)  # resizes image in-place
       34     train_images.append([np.array(img), one_hot_label(i)])
  
  ~\Anaconda3\lib\site-packages\PIL\Image.py in open(fp, mode)
     2768 
     2769     if filename:
  -&gt; 2770         fp = builtins.open(filename, "rb")
     2771         exclusive_fp = True
     2772 
  
  PermissionError: [Errno 13] Permission denied: 'C:/Users/Will Downs/image_training/training_data/Airplane'
  </code></pre>
  
  <p>Any suggestions on why this is or how I can fix it?</p>