FileNotFoundError: [Errno 2] No such file or directory: ‘config.yaml’

(my_project) C:\my_project\NORNIR>cd…

(my_project) C:\my_project>python c:\my_project\NORNIR\EFN2\
Traceback (most recent call last):
File “c:\my_project\NORNIR\EFN2\”, line 5, in
nr = InitNornir(config_file=“config.yaml”)
File “c:\my_project\lib\site-packages\nornir\”, line 54, in InitNornir
conf = Config.load_from_file(config_file, **kwargs)
File “c:\my_project\lib\site-packages\nornir\core\deserializer\”, line 203, in load_from_file
with open(config_file, “r”) as f:
FileNotFoundError: [Errno 2] No such file or directory: ‘config.yaml’

(my_project) C:\my_project>python
Python 3.8.3 (tags/v3.8.3:6f8c832, May 13 2020, 22:20:19) [MSC v.1925 32 bit (Intel)] on win32
Type “help”, “copyright”, “credits” or “license” for more information.

This post will be helpful to you.

When you open a file with the file name , you are telling the open() function that your file is in the current working directory. This is called a relative path. If the user does not pass the full path to the file (on Unix type systems this means a path that starts with a slash), the path is interpreted relatively to the current working directory. The current working directory usually is the directory in which you started the program. A good start would be validating the input. In other words, you can make sure that the user has indeed typed a correct path for a real existing file, like this:

while not os.path.isfile(fileName):
    fileName = input("Whoops! No such file! Please enter the name of the file you'd like to use.")

Another way to tell the python file open() function where your file is located is by using an absolute path, e.g.:

f = open("/Users/foo/filename")