1

I see that this is a common issue but I have yet to see a fix for it. I am using the latest pycharm community, and i am running a script from the python console, but any time I try to load matplotlib or stellargraph in particular, I get the following:

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'

Has anyone found a fix for this? Is it a setting in the interpreter or the console itself? I checked that i have ipython as well. Please help! Thanks in advance.

TSirico
  • 35
  • 5
  • Did you try the solutions listed here ? https://stackoverflow.com/questions/58203394/unable-to-import-package-issues-with-inputhookmanager – Sonia Samipillai Sep 01 '21 at 01:24
  • 1
    @Sonia they'll work for matplotlib, but not stellargraph. I checked my ipython and its the latest one as well. – TSirico Sep 01 '21 at 01:31
  • Could you please edit the question to stellargraph? Since it also mentions matplotlib, I had thought the already existing solution might help :) – Sonia Samipillai Sep 01 '21 at 02:13

1 Answers1

0

Found the solution:

GoTo: Run -> Edit Configurations

Under Environment, there is "Environment Variables", ensure DISPLAY=True is in the box, click enter.

Fixed it for me.

TSirico
  • 35
  • 5