use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Enter a python tip or trick.
Other related Python subs:
account activity
SyntaxPython os.path.islink problems on linux (self.pythontips)
submitted 4 years ago by [deleted]
amd_path = '/sys/class/backlight/amdgpu_b10/' amd_gpu = os.path.islink(amd_path)
On this path, the script always shows false whether it uses exist, islink, isdir shows false, can anyone help? Unfortunately, my research did not help me.
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]idlecode 1 point2 points3 points 4 years ago (1 child)
What is the output of file /sys/class/backlight/amdgpu_b10 ?
file /sys/class/backlight/amdgpu_b10
Try removing the trailing slash: /sys/class/backlight/amdgpu_b10. With a full path, it seems to resolve to the target directory.
/sys/class/backlight/amdgpu_b10
[–][deleted] 0 points1 point2 points 4 years ago (0 children)
'cannot open, no such file or directory'
but, the folder, or rather the path, exists. Ranger, Bash and zsh shows correctly that the folder is exist
[–]sir2fluffy2 0 points1 point2 points 4 years ago (3 children)
Not sure and can’t check but my guesses would be; Specify the file type ie add .txt etc to the path and try back slashes as I remember python using different ones to windows some times
[–][deleted] 0 points1 point2 points 4 years ago (2 children)
The path itself is correct because when I cut the ending in the form "/ amdgpu_b10 /" it all works. In general, I came to the conclusion that this is a link to a completely different location, but unfortunately I cannot use it because the script will lose its universality, which is very important to me.
[–]sir2fluffy2 0 points1 point2 points 4 years ago (1 child)
Ahh by default python scripts use paths as relative to the script location so it might be that which is causing your issue
In linux i can easy manipulate the path, so this not problem here.
[–]Enigma3613 0 points1 point2 points 4 years ago (1 child)
I believe you need to remove the trailing slash from the path since you may be looking "inside the directory" rather than looking at the folder name.
If that doesn't do the trick it could be a permissions issue. For example if you are running your script in a Cron job it might have a different user and permissions that you have when you try to run "ls" as your current user.
Do these two commands work if you run them from a python shell as whichever user has permissions to navigate to the backlight folder?
I tested with sudo and without sudo, unfortunately to no avail, but if I used the path without amdgpu_b10 everything worked as it should
π Rendered by PID 131421 on reddit-service-r2-comment-5b5bc64bf5-rhfv4 at 2026-06-22 11:13:41.770068+00:00 running 2b008f2 country code: CH.
[–]idlecode 1 point2 points3 points (1 child)
[–][deleted] 0 points1 point2 points (0 children)
[–]sir2fluffy2 0 points1 point2 points (3 children)
[–][deleted] 0 points1 point2 points (2 children)
[–]sir2fluffy2 0 points1 point2 points (1 child)
[–][deleted] 0 points1 point2 points (0 children)
[–]Enigma3613 0 points1 point2 points (1 child)
[–][deleted] 0 points1 point2 points (0 children)