PyCharm无法访问/ usr / lib /和/ usr / bin /中的文件

问题描述

我在Pop_OS下将 PyCharm 2020.2.3 Python 3.8.6 一起使用! 20.10(您可能会像使用 Ubuntu 20.10 一样进行操作),该软件无法看到ifstream Dictionary(Dict); char c; while (Dictionary.get(c)) { //write character and its code to a map } /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'))

但是当我在PyCharm中运行它时,它像这样失败:

>>> python main.py
True
True
<_io.TextIOWrapper name='/usr/lib/firefox/firefox' mode='r' encoding='UTF-8'>

以下是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

关于类似问题,有很多问题,但是大多数问题最终都提出了与所需特定文件相关的解决方法

似乎存在某种许可问题,我想解决这个问题而不必依靠解决方法

解决方法

一个多月后,我发现this thread on intellij-support解释了此问题的发生,因为我安装了PyCharm扁平包装。

我最终发现我的问题是由我的安装方式引起的 pycharm。我曾经在App Store上安装过Flatpack。由于 Flatpack如何工作,它安装了一个隔离的环境,其中包含 应用所需的一切。对于普通的应用程序,这可能对 重复文件的使用会占用额外的磁盘空间,但对于 开发应用程序,它使您无法从以下位置可靠地运行代码 在flatpack已安装的应用程序中。

-Mvanorder1390(创建于2019年10月30日13:13)

这正是我的问题。我从官方来源重新安装了PyCharm,而不是从我的应用程序商店重新安装,后者仅提供平板包装版本,并且现在所有内容都像吊饰一样(无双关语)!