Skip to content
Advertisement

log file error in in Raspberry with Python

I am use Python3 in my Raspberry Pi, and I have a code that someone has shared with me, the following line is shown to record the log file:

JavaScript

but when I tray to run the code using Python on my Raspberry I get the following error:

JavaScript

I have also created the directory and the file manually but I get this other error:

JavaScript

what am I doing wrong

Advertisement

Answer

It is simply because the file that you are trying to log on does not actually exist. You could either create it manually, or use the below version of your Python script which will create it for you, if it does not exist already:

JavaScript

However make sure that the path to that log file is actually correct. To be extra sure, use the absolute path. You are looking to something like:

/home/pi/Destkop/...

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement