With PyCharm community edition 2024.3.1.1 under Linux mint i'm get an exception when calling os.stat on system files like "/usr/bin/chromium". Calling the same script as the same user with the python interpreter directly it works.
Example script test.py:
import os
if __name__ == '__main__':
print( os.stat("/usr/bin/chromium") )
produces following error:
File "/home/user/test.py", line 4, in <module>
print( os.stat("/usr/bin/chromium") )
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
FileNotFoundError: [Errno 2] No such file or directory: '/usr/bin/chromium'
Interpreter used in pycharm is /usr/bin/python3.
When call script directly with
/usr/bin/python3 test.py
everything works as expected.
Whats the reason and how to get the script run within pycharm?
Generally, this means that pycharm is running inside a sandbox. If you installed it with a tool such as snap or flatpak, this is typical and intended behavior.
If you want processes that pycharm starts to have the same permissions as your regular user account, avoid using a package manager that sets up sandboxing to install it.