Python Forum

Full Version: FileNotFoundError: [Errno 2] No such file or directory although the file exists
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I am defining a logger and periodically exporting the content to a blob. I’ve been using this for some time with DBR 10.4/python 3.8 without any issue. However we’ve moved to DBR 15.2/python 3.11, and now the logger function is working as expected. But when I’m trying to read and export it it’s throwing the following error:

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

I additionally tried to specify a log folder and use the logpath + filename to create the log and read it. Although the logs are created but iIt’s still throwing the same error. After getting the error if I run
Quote:os.listdir(logpath)
I don’t see the missing logfile in the list. But if I run
Quote:%sh ls -als logpath
I can see the ‘missing’ log file listed. If I run
Quote:os.listdir(logpath)
again, the missing logfiles appear in the list.

I’ve also tried the following in both environment:
(print(os.popen("id").read()))
(print(os.popen(r"/Workspace/Users/[email protected]/log").read()))

For both env, I’m getting
Quote:uid=0(root) gid=0(root) groups=0(root)
for the first command. But for the second command I’m getting blank in 3.8 env &
Quote:/bin/sh: 1: /logpath: Permission denied
in 3.11 respectively.

I haven’t posted any of the codes as I'm not sure which part would be relevant for this issue, but I can post the required part of the code as well in a follow up comment. A detailed post on the same topic with codes can be found here: https://stackoverflow.com/questions/7879...2_78793965

Any help will be welcome on this issue. Thanks in advance!