Pycharm 后端问题

Pycharm backend issue

我发现这是一个常见问题,但我还没有找到解决方法。我使用的是最新的 pycharm 社区,我是 运行 来自 python 控制台的脚本,但每当我尝试加载 matplotlib 或 stellargraph 时,我都会得到以下信息:

Traceback (most recent call last):
  File "/home/anthony/School/Research/Projects/my_code/venv/lib64/python3.8/site-packages/lib/python3.8/site-packages/IPython/core/interactiveshell.py", line 3441, in run_code
    exec(code_obj, self.user_global_ns, self.user_ns)
  File "<ipython-input-4-d181923c6965>", line 1, in <module>
    exec(open('main.py').read())
  File "<string>", line 5, in <module>
  File "/snap/pycharm-community/250/plugins/python-ce/helpers/pydev/_pydev_bundle/pydev_import_hook.py", line 21, in do_import
    module = self._system_import(name, *args, **kwargs)
  File "/home/anthony/School/Research/Projects/my_code/venv/lib64/python3.8/site-packages/lib/python3.8/site-packages/stellargraph/__init__.py", line 39, in <module>
    from stellargraph import (
  File "/snap/pycharm-community/250/plugins/python-ce/helpers/pydev/_pydev_bundle/pydev_import_hook.py", line 21, in do_import
    module = self._system_import(name, *args, **kwargs)
  File "/home/anthony/School/Research/Projects/my_code/venv/lib64/python3.8/site-packages/lib/python3.8/site-packages/stellargraph/calibration.py", line 29, in <module>
    import matplotlib.pyplot as plt
  File "/snap/pycharm-community/250/plugins/python-ce/helpers/pydev/_pydev_bundle/pydev_import_hook.py", line 21, in do_import
    module = self._system_import(name, *args, **kwargs)
  File "/home/anthony/.local/lib/python3.8/site-packages/matplotlib/pyplot.py", line 2507, in <module>
    install_repl_displayhook()
  File "/home/anthony/.local/lib/python3.8/site-packages/matplotlib/pyplot.py", line 156, in install_repl_displayhook
    ip.enable_gui(ipython_gui_name)
  File "/snap/pycharm-community/250/plugins/python-ce/helpers/pydev/_pydev_bundle/pydev_ipython_console_011.py", line 156, in enable_gui
    return real_enable_gui(gui, app)
  File "/snap/pycharm-community/250/plugins/python-ce/helpers/pydev/pydev_ipython/inputhook.py", line 536, in enable_gui
    return gui_hook(app)
  File "/snap/pycharm-community/250/plugins/python-ce/helpers/pydev/pydev_ipython/inputhook.py", line 413, in enable_gtk3
    self.set_inputhook(create_inputhook_gtk3(self._stdin_file))
AttributeError: 'InputHookManager' object has no attribute '_stdin_file'

有人找到解决办法了吗?它是解释器中的设置还是控制台本身?我检查过我也有 ipython。请帮忙!提前致谢。

找到解决方案:

转到:运行 -> 编辑配置

在Environment下,有“Environment Variables”,确保DISPLAY=True在框中,点击进入。

帮我修好了。