Errors from os.scandir were not catched. In addition the path to run scandir was not properly created