Traceback (most recent call last):
File "D:\Seneca\7th_Term\DPS909\New folder\Magic-SSG\magic_ssg.py", line 116, in <module>
main()
File "D:\Seneca\7th_Term\DPS909\New folder\Magic-SSG\magic_ssg.py", line 113, in main
output_result(file, html)
File "D:\Seneca\7th_Term\DPS909\New folder\Magic-SSG\magic_ssg.py", line 85, in output_result
with open(file_path, "w", encoding="utf8") as output_file:
FileNotFoundError: [Errno 2] No such file or directory: 'dist/sample/Silver Blaze.html'
Description:
The program is trying to create dist/sample/Silver Blaze.html file, but the dist/sample folder doesn't exist, so the error is produced. To fix this, dist/sample needs to be created first, before trying to open/create the HTML file. This can be done using the os.makedirs() command (check documentation).
On a side note, since Silver Blaze.html is directly under sample, which is the input folder, it should be generated directly under dist. The input folder should not be re-created inside the output folder, only its file structure and subfolders need to be replicated. For example:
input folder
output folder
To do this, you can try getting the path from the input folder to the file using os.walk and os.path.join, and then recreate the subfolders inside the output folder using os.makedirs(), before calling open() to create and write to the HTML files.
Command
Input Folder Structure
Error
Description:
The program is trying to create
dist/sample/Silver Blaze.html
file, but thedist/sample
folder doesn't exist, so the error is produced. To fix this,dist/sample
needs to be created first, before trying to open/create the HTML file. This can be done using theos.makedirs()
command (check documentation).On a side note, since
Silver Blaze.html
is directly undersample
, which is the input folder, it should be generated directly underdist
. The input folder should not be re-created inside the output folder, only its file structure and subfolders need to be replicated. For example:input folder
output folder
To do this, you can try getting the path from the input folder to the file using
os.walk
andos.path.join
, and then recreate the subfolders inside the output folder usingos.makedirs()
, before callingopen()
to create and write to the HTML files.