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

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!

Stack Overflow Asked by Chloe Wong on January 5, 2022

0 Answers

Add your own answers!

Related Questions

Pandas dataframe only select the columns that have all True

2  Asked on December 11, 2020 by learningisfun


I want to create fixed sidebar but scroll does not work

5  Asked on December 11, 2020 by nav


How can I extract all PDF Tags related to content with Python?

2  Asked on December 11, 2020 by martin-thoma


React Fizz-Buzz

2  Asked on December 11, 2020 by kamil-kos


Update Subform based on Form Combo Box

0  Asked on December 10, 2020 by hazat-bangurah


Determine if __getattr__ is method or attribute call

3  Asked on December 10, 2020 by robin-orheden


How to implement category axis in matplotlib?

0  Asked on December 10, 2020 by fgg1991


Pre-fill the checkbox with url

2  Asked on December 10, 2020 by sevenine


Shell=false generates OsError

1  Asked on December 10, 2020 by azza-abidi


LINQ query orderBy a subquery

2  Asked on December 9, 2020 by golfbravo


Ask a Question

Get help from others!

© 2022 All rights reserved.