I'm trying to write a binary file i'm downloading from The Movie Database. I can successfully save the file if it's on the same folder the .py file is, but cannot save it on a location outside it even after the containing directory is created by the script and using absolute path:
FileNotFoundError: [Errno 2] No such file or directory: '/home/gabriel/Desktop/movies/w185/tt2024544.jpeg'
Pice of code:
filepath = os.path.join(webDir,size,imdbid + '.' + filetype);
f = open(filepath, "wb");
I'm puzzled. Any tips?
Thanks!
I had the same issue and it turned out that a directory in my absolute path was not existing. One can easily check with:
import os
path = os.path.split(filepath)[0]
print('check for path', os.path.exists(path))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With