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

Dan Stromberg drsalists at gmail.com
Wed Apr 14 13:35:22 EDT 2021


On Wed, Apr 14, 2021 at 9:14 AM Quentin Bock <qberz2005 at gmail.com> wrote:

> I receive this error when I try to open a file
> The file (what I'm trying to open) is in the same folder as the program I'm
> trying to open it from; why is it saying no such file or directory?
>
> this is the only part of the code that causes the error
>
> file = open('Egils Saga 1-15.txt', "r")
>
> file.close()
>

Python will try to open the file in the directory you are currently in,
rather than the directory your program is in.

Try cd'ing to the appropriate directory first.  Or specify a full to your
file in the open.


More information about the Python-list mailing list