"FileNotFoundError: [Errno 2] No such file or directory:" despite using full path

Stack Overflow Asked by Chloe Wong on January 5, 2022

Just wondering if someone might be able to point me in the right direction as I’m at complete loss of what’s happening (I’m a beginner so sorry if this is blaringly obvious!).

I’m writing some code to create a photomosaic. It requires resizing photos from a database and then concating images together to create a bigger picture.

The relevant code is as follows:

def resize(self):
        path = "C:/Users/chloe/Desktop/Python_Stuffs/Robert_Heaton/landscape_images"
        dirs = os.listdir(path)
        new_path = Path(path, 'resized_pics')
        new_path.mkdir(parents=True, exist_ok=True)
 def concat_rows(self):
        path = "C:/Users/chloe/Desktop/Python_Stuffs/Robert_Heaton"
        new_path_concat = Path(path, 'photomosaic_images_' + im_name)
        new_path_concat.mkdir(parents=True, exist_ok=True)
        counter = 0
        for row in self.match_pixel_img:
            im1_path = os.path.join(self.new_path,row.pop(0))
            im1 =

In the function resize I create a new directory with the new resized pictures in, and then in concat_rows I take the resized images from the new directory and concat them. However, I’m getting this error:

    File "", line 95, in concat_rows
    im1 =

    File "", line 2878, in open
    fp =, "rb")

    FileNotFoundError: [Errno 2] No such file or directory: 

even though this is the directory I created in resize and I can SEE the directory in my files at that exact location. I’m using the fullpath so I’m really not sure what is wrong. Furthermore, when I run the code a second time it works fine so maybe it’s something to do with the way Python reads lines?

If anyone could shed some light I’d be really grateful!

Add your own answers!

Related Questions

Java writing unlimited text lines to a UI

0  Asked on February 11, 2021 by barry-griffey


R simple dplyr solution to filter

3  Asked on February 11, 2021 by triss


Go back browser button action

2  Asked on February 11, 2021 by ljopata


How to pass array to funtion to use as range based for loop

3  Asked on February 10, 2021 by aniket-ujgare


react ref and query selector all

2  Asked on February 10, 2021 by peter-flanagan


Direct code execution through the JS browser console

0  Asked on February 10, 2021 by matheus-nascimento


How to correctly write word-break in css?

3  Asked on February 10, 2021 by aiko-schurmann


Finding a user data based on email

1  Asked on February 10, 2021 by aamer-salame


Can I use text when using functions? Or only numbers?

4  Asked on February 9, 2021 by osk6r


Get the string before replace

0  Asked on February 9, 2021 by tanker


Ask a Question

Get help from others!

© 2023 All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP