Jump to content

NotADirectoryError Python error

Go to solution Solved by fizzlesticks,

.ds_store is a file, not a folder. You're calling the line

img_list = os.listdir(img_fold_A)

for everything in the folder, which of course causes an error when you call it with a file.

 

You could either delete the .ds_store file at the start or add a check to skip files.

are you sure .DS_Store is a folder and not a file?

                     ¸„»°'´¸„»°'´ Vorticalbox `'°«„¸`'°«„¸
`'°«„¸¸„»°'´¸„»°'´`'°«„¸Scientia Potentia est  ¸„»°'´`'°«„¸`'°«„¸¸„»°'´

Link to post
Share on other sites

.ds_store is a file, not a folder. You're calling the line

img_list = os.listdir(img_fold_A)

for everything in the folder, which of course causes an error when you call it with a file.

 

You could either delete the .ds_store file at the start or add a check to skip files.

1474412270.2748842

Link to post
Share on other sites

6 minutes ago, RexLee said:

Thanks it worked after I deleted the .ds_store file. Why does it cause the error though? Isn't /Users/rexlee/Desktop/A a folder when I pass it?

In the line 

splits = os.listdir(args.fold_A)

yes that works fine because "/Users/rexlee/Desktop/A" is a folder.

Inside the loop when you do 

img_fold_A = os.path.join(args.fold_A, sp)
img_fold_B = os.path.join(args.fold_B, sp)
img_list = os.listdir(img_fold_A)

args.fold_A = "/Users/rexlee/Desktop/A"

sp = ".DS_Store"

which makes

img_fold_A = "/Users/rexlee/Desktop/A/.DS_Store" which is a file.

1474412270.2748842

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×