【发布时间】:2021-02-16 08:43:21
【问题描述】:
我在 Pop_OS 下使用 PyCharm 2020.2.3 和 Python 3.8.6! 20.10(你可以像我使用 Ubuntu 20.10 一样)无法在/usr/bin 或/usr/lib 中看到文件。
如果我尝试触摸/usr/lib/firefox/firefox 二进制文件,这是一个示例。
# main.py
import os
print(os.path.exists('/usr/lib'))
print(os.path.exists('/usr/lib/firefox'))
print(open('/usr/lib/firefox/firefox', 'r'))
从命令行,这是有效的:
>>> python main.py
True
True
<_io.TextIOWrapper name='/usr/lib/firefox/firefox' mode='r' encoding='UTF-8'>
但是当我在 PyCharm 中运行它时,它会像这样失败:
True # Can see /usr/lib
False # Cannot see /usr/lib/firefox
Traceback (most recent call last):
File ..., line 5, in <module>
print(open('/usr/lib/firefox/firefox', 'r'))
FileNotFoundError: [Errno 2] No such file or directory: '/usr/lib/firefox/firefox'
这里是usr/bin/firefox的权限:
>>> ls -ld firefox
drwxr-xr-x 8 root root 4096 Oct 26 10:22 firefox
有许多关于类似问题的问题,但其中大多数最终建议解决与所需特定文件相关的工作。
似乎存在某种许可问题,我想解决这个问题,而不必依赖解决方法。
【问题讨论】:
标签: python python-3.x permissions pycharm python-os