Cannot load matplotlib when "show plot in tool window" is disabled

Answered

Good morning,

I am using Ubuntu 16.04 and a conda virtual environment with Python 3.6.

I do not want to use the Scientific mode, therefore, in the "View" menu I did not enable the "Scientific mode" and in "Settings->Tools->Python Scientific" I disabled "show plot in tool window". Now, if I try to import matplotlib from the Python console, I get the following error:

Matplotlib support failed
Traceback (most recent call last):
  File "/home/EU/derossim/pycharm-2018.2.4/helpers/pydev/_pydev_bundle/pydev_import_hook.py", line 23, in do_import
    succeeded = activate_func()
  File "/home/EU/derossim/pycharm-2018.2.4/helpers/pydev/_pydev_bundle/pydev_console_utils.py", line 199, in <lambda>
    "matplotlib": lambda: activate_matplotlib(self.enableGui),
  File "/home/EU/derossim/pycharm-2018.2.4/helpers/pydev/pydev_ipython/matplotlibtools.py", line 96, in activate_matplotlib
    gui, backend = find_gui_and_backend()
  File "/home/EU/derossim/pycharm-2018.2.4/helpers/pydev/pydev_ipython/matplotlibtools.py", line 47, in find_gui_and_backend
    backend = matplotlib.rcParams['backend']
  File "/home/EU/derossim/miniconda3/envs/confidence_prediction/lib/python3.6/site-packages/matplotlib/__init__.py", line 892, in __getitem__
    plt.switch_backend(rcsetup._auto_backend_sentinel)
AttributeError: module 'matplotlib.pyplot' has no attribute 'switch_backend'
Matplotlib support failed
Traceback (most recent call last):
  File "/home/EU/derossim/pycharm-2018.2.4/helpers/pydev/_pydev_bundle/pydev_import_hook.py", line 23, in do_import
    succeeded = activate_func()
  File "/home/EU/derossim/pycharm-2018.2.4/helpers/pydev/_pydev_bundle/pydev_console_utils.py", line 199, in <lambda>
    "matplotlib": lambda: activate_matplotlib(self.enableGui),
  File "/home/EU/derossim/pycharm-2018.2.4/helpers/pydev/pydev_ipython/matplotlibtools.py", line 96, in activate_matplotlib
    gui, backend = find_gui_and_backend()
  File "/home/EU/derossim/pycharm-2018.2.4/helpers/pydev/pydev_ipython/matplotlibtools.py", line 47, in find_gui_and_backend
    backend = matplotlib.rcParams['backend']
  File "/home/EU/derossim/miniconda3/envs/confidence_prediction/lib/python3.6/site-packages/matplotlib/__init__.py", line 892, in __getitem__
    plt.switch_backend(rcsetup._auto_backend_sentinel)
AttributeError: module 'matplotlib.pyplot' has no attribute 'switch_backend'
Matplotlib support failed
Traceback (most recent call last):
  File "/home/EU/derossim/pycharm-2018.2.4/helpers/pydev/_pydev_bundle/pydev_import_hook.py", line 23, in do_import
    succeeded = activate_func()
  File "/home/EU/derossim/pycharm-2018.2.4/helpers/pydev/_pydev_bundle/pydev_console_utils.py", line 199, in <lambda>
    "matplotlib": lambda: activate_matplotlib(self.enableGui),
  File "/home/EU/derossim/pycharm-2018.2.4/helpers/pydev/pydev_ipython/matplotlibtools.py", line 96, in activate_matplotlib
    gui, backend = find_gui_and_backend()
  File "/home/EU/derossim/pycharm-2018.2.4/helpers/pydev/pydev_ipython/matplotlibtools.py", line 47, in find_gui_and_backend
    backend = matplotlib.rcParams['backend']
  File "/home/EU/derossim/miniconda3/envs/confidence_prediction/lib/python3.6/site-packages/matplotlib/__init__.py", line 892, in __getitem__
    plt.switch_backend(rcsetup._auto_backend_sentinel)
AttributeError: module 'matplotlib.pyplot' has no attribute 'switch_backend'
Matplotlib support failed
Traceback (most recent call last):
  File "/home/EU/derossim/pycharm-2018.2.4/helpers/pydev/_pydev_bundle/pydev_import_hook.py", line 23, in do_import
    succeeded = activate_func()
  File "/home/EU/derossim/pycharm-2018.2.4/helpers/pydev/_pydev_bundle/pydev_console_utils.py", line 199, in <lambda>
    "matplotlib": lambda: activate_matplotlib(self.enableGui),
  File "/home/EU/derossim/pycharm-2018.2.4/helpers/pydev/pydev_ipython/matplotlibtools.py", line 96, in activate_matplotlib
    gui, backend = find_gui_and_backend()
  File "/home/EU/derossim/pycharm-2018.2.4/helpers/pydev/pydev_ipython/matplotlibtools.py", line 47, in find_gui_and_backend
    backend = matplotlib.rcParams['backend']
  File "/home/EU/derossim/miniconda3/envs/confidence_prediction/lib/python3.6/site-packages/matplotlib/__init__.py", line 891, in __getitem__
    from matplotlib import pyplot as plt
  File "/home/EU/derossim/pycharm-2018.2.4/helpers/pydev/_pydev_bundle/pydev_import_hook.py", line 20, in do_import
    module = self._system_import(name, *args, **kwargs)
RecursionError: maximum recursion depth exceeded while calling a Python object
Fatal Python error: Cannot recover from stack overflow.
Thread 0x00007f45e5727700 (most recent call first):
  File "/home/EU/derossim/miniconda3/envs/confidence_prediction/lib/python3.6/selectors.py", line 376 in select
  File "/home/EU/derossim/miniconda3/envs/confidence_prediction/lib/python3.6/socketserver.py", line 236 in serve_forever
  File "/home/EU/derossim/pycharm-2018.2.4/helpers/pydev/pydevconsole.py", line 302 in start_console_server
Current thread 0x00007f45e87fb700 (most recent call first):
  File "<frozen importlib._bootstrap>", line 219 in _call_with_frames_removed
  File "<frozen importlib._bootstrap>", line 1023 in _handle_fromlist
  File "/home/EU/derossim/pycharm-2018.2.4/helpers/pydev/_pydev_bundle/pydev_import_hook.py", line 20 in do_import
  File "/home/EU/derossim/miniconda3/envs/confidence_prediction/lib/python3.6/site-packages/matplotlib/__init__.py", line 891 in __getitem__
  File "/home/EU/derossim/pycharm-2018.2.4/helpers/pydev/pydev_ipython/matplotlibtools.py", line 47 in find_gui_and_backend
  File "/home/EU/derossim/pycharm-2018.2.4/helpers/pydev/pydev_ipython/matplotlibtools.py", line 96 in activate_matplotlib
  File "/home/EU/derossim/pycharm-2018.2.4/helpers/pydev/_pydev_bundle/pydev_console_utils.py", line 199 in <lambda>
  File "/home/EU/derossim/pycharm-2018.2.4/helpers/pydev/_pydev_bundle/pydev_import_hook.py", line 23 in do_import
  File "/home/EU/derossim/miniconda3/envs/confidence_prediction/lib/python3.6/site-packages/matplotlib/__init__.py", line 891 in __getitem__
  File "/home/EU/derossim/pycharm-2018.2.4/helpers/pydev/pydev_ipython/matplotlibtools.py", line 47 in find_gui_and_backend
  File "/home/EU/derossim/pycharm-2018.2.4/helpers/pydev/pydev_ipython/matplotlibtools.py", line 96 in activate_matplotlib
  File "/home/EU/derossim/pycharm-2018.2.4/helpers/pydev/_pydev_bundle/pydev_console_utils.py", line 199 in <lambda>
  File "/home/EU/derossim/pycharm-2018.2.4/helpers/pydev/_pydev_bundle/pydev_import_hook.py", line 23 in do_import
  File "/home/EU/derossim/miniconda3/envs/confidence_prediction/lib/python3.6/site-packages/matplotlib/__init__.py", line 891 in __getitem__
  File "/home/EU/derossim/pycharm-2018.2.4/helpers/pydev/pydev_ipython/matplotlibtools.py", line 47 in find_gui_and_backend
  File "/home/EU/derossim/pycharm-2018.2.4/helpers/pydev/pydev_ipython/matplotlibtools.py", line 96 in activate_matplotlib
  File "/home/EU/derossim/pycharm-2018.2.4/helpers/pydev/_pydev_bundle/pydev_console_utils.py", line 199 in <lambda>
  File "/home/EU/derossim/pycharm-2018.2.4/helpers/pydev/_pydev_bundle/pydev_import_hook.py", line 23 in do_import
  File "/home/EU/derossim/miniconda3/envs/confidence_prediction/lib/python3.6/site-packages/matplotlib/__init__.py", line 891 in __getitem__
  File "/home/EU/derossim/pycharm-2018.2.4/helpers/pydev/pydev_ipython/matplotlibtools.py", line 47 in find_gui_and_backend
  File "/home/EU/derossim/pycharm-2018.2.4/helpers/pydev/pydev_ipython/matplotlibtools.py", line 96 in activate_matplotlib
  File "/home/EU/derossim/pycharm-2018.2.4/helpers/pydev/_pydev_bundle/pydev_console_utils.py", line 199 in <lambda>
  File "/home/EU/derossim/pycharm-2018.2.4/helpers/pydev/_pydev_bundle/pydev_import_hook.py", line 23 in do_import
  File "/home/EU/derossim/miniconda3/envs/confidence_prediction/lib/python3.6/site-packages/matplotlib/__init__.py", line 891 in __getitem__
  File "/home/EU/derossim/pycharm-2018.2.4/helpers/pydev/pydev_ipython/matplotlibtools.py", line 47 in find_gui_and_backend
  File "/home/EU/derossim/pycharm-2018.2.4/helpers/pydev/pydev_ipython/matplotlibtools.py", line 96 in activate_matplotlib
  File "/home/EU/derossim/pycharm-2018.2.4/helpers/pydev/_pydev_bundle/pydev_console_utils.py", line 199 in <lambda>
  File "/home/EU/derossim/pycharm-2018.2.4/helpers/pydev/_pydev_bundle/pydev_import_hook.py", line 23 in do_import
  File "/home/EU/derossim/miniconda3/envs/confidence_prediction/lib/python3.6/site-packages/matplotlib/backends/backend_macosx.py", line 9 in <module>
  File "<frozen importlib._bootstrap>", line 219 in _call_with_frames_removed
  File "<frozen importlib._bootstrap_external>", line 678 in exec_module
  File "<frozen importlib._bootstrap>", line 665 in _load_unlocked
  File "<frozen importlib._bootstrap>", line 955 in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 971 in _find_and_load
  File "<frozen importlib._bootstrap>", line 994 in _gcd_import
  File "/home/EU/derossim/miniconda3/envs/confidence_prediction/lib/python3.6/importlib/__init__.py", line 126 in import_module
  File "/home/EU/derossim/miniconda3/envs/confidence_prediction/lib/python3.6/site-packages/matplotlib/pyplot.py", line 207 in switch_backend
  File "/home/EU/derossim/miniconda3/envs/confidence_prediction/lib/python3.6/site-packages/matplotlib/pyplot.py", line 196 in switch_backend
  File "/home/EU/derossim/miniconda3/envs/confidence_prediction/lib/python3.6/site-packages/matplotlib/__init__.py", line 892 in __getitem__
  File "/home/EU/derossim/pycharm-2018.2.4/helpers/pydev/pydev_ipython/matplotlibtools.py", line 47 in find_gui_and_backend
  File "/home/EU/derossim/pycharm-2018.2.4/helpers/pydev/pydev_ipython/matplotlibtools.py", line 96 in activate_matplotlib
  File "/home/EU/derossim/pycharm-2018.2.4/helpers/pydev/_pydev_bundle/pydev_console_utils.py", line 199 in <lambda>
  File "/home/EU/derossim/pycharm-2018.2.4/helpers/pydev/_pydev_bundle/pydev_import_hook.py", line 23 in do_import
  File "/home/EU/derossim/miniconda3/envs/confidence_prediction/lib/python3.6/site-packages/matplotlib/__init__.py", line 891 in __getitem__
  File "/home/EU/derossim/pycharm-2018.2.4/helpers/pydev/pydev_ipython/matplotlibtools.py", line 47 in find_gui_and_backend
  File "/home/EU/derossim/pycharm-2018.2.4/helpers/pydev/pydev_ipython/matplotlibtools.py", line 96 in activate_matplotlib
  File "/home/EU/derossim/pycharm-2018.2.4/helpers/pydev/_pydev_bundle/pydev_console_utils.py", line 199 in <lambda>
  File "/home/EU/derossim/pycharm-2018.2.4/helpers/pydev/_pydev_bundle/pydev_import_hook.py", line 23 in do_import
  File "/home/EU/derossim/miniconda3/envs/confidence_prediction/lib/python3.6/site-packages/matplotlib/__init__.py", line 891 in __getitem__
  File "/home/EU/derossim/pycharm-2018.2.4/helpers/pydev/pydev_ipython/matplotlibtools.py", line 47 in find_gui_and_backend
  File "/home/EU/derossim/pycharm-2018.2.4/helpers/pydev/pydev_ipython/matplotlibtools.py", line 96 in activate_matplotlib
  File "/home/EU/derossim/pycharm-2018.2.4/helpers/pydev/_pydev_bundle/pydev_console_utils.py", line 199 in <lambda>
  File "/home/EU/derossim/pycharm-2018.2.4/helpers/pydev/_pydev_bundle/pydev_import_hook.py", line 23 in do_import
  File "/home/EU/derossim/miniconda3/envs/confidence_prediction/lib/python3.6/site-packages/matplotlib/__init__.py", line 891 in __getitem__
  File "/home/EU/derossim/pycharm-2018.2.4/helpers/pydev/pydev_ipython/matplotlibtools.py", line 47 in find_gui_and_backend
  File "/home/EU/derossim/pycharm-2018.2.4/helpers/pydev/pydev_ipython/matplotlibtools.py", line 96 in activate_matplotlib
  File "/home/EU/derossim/pycharm-2018.2.4/helpers/pydev/_pydev_bundle/pydev_console_utils.py", line 199 in <lambda>
  File "/home/EU/derossim/pycharm-2018.2.4/helpers/pydev/_pydev_bundle/pydev_import_hook.py", line 23 in do_import
  File "/home/EU/derossim/miniconda3/envs/confidence_prediction/lib/python3.6/site-packages/matplotlib/__init__.py", line 891 in __getitem__
  File "/home/EU/derossim/pycharm-2018.2.4/helpers/pydev/pydev_ipython/matplotlibtools.py", line 47 in find_gui_and_backend
  File "/home/EU/derossim/pycharm-2018.2.4/helpers/pydev/pydev_ipython/matplotlibtools.py", line 96 in activate_matplotlib
  File "/home/EU/derossim/pycharm-2018.2.4/helpers/pydev/_pydev_bundle/pydev_console_utils.py", line 199 in <lambda>
  File "/home/EU/derossim/pycharm-2018.2.4/helpers/pydev/_pydev_bundle/pydev_import_hook.py", line 23 in do_import
  File "/home/EU/derossim/miniconda3/envs/confidence_prediction/lib/python3.6/site-packages/matplotlib/__init__.py", line 891 in __getitem__
  File "/home/EU/derossim/pycharm-2018.2.4/helpers/pydev/pydev_ipython/matplotlibtools.py", line 47 in find_gui_and_backend
  File "/home/EU/derossim/pycharm-2018.2.4/helpers/pydev/pydev_ipython/matplotlibtools.py", line 96 in activate_matplotlib
  File "/home/EU/derossim/pycharm-2018.2.4/helpers/pydev/_pydev_bundle/pydev_console_utils.py", line 199 in <lambda>
  File "/home/EU/derossim/pycharm-2018.2.4/helpers/pydev/_pydev_bundle/pydev_import_hook.py", line 23 in do_import
  File "/home/EU/derossim/miniconda3/envs/confidence_prediction/lib/python3.6/site-packages/matplotlib/__init__.py", line 891 in __getitem__
  File "/home/EU/derossim/pycharm-2018.2.4/helpers/pydev/pydev_ipython/matplotlibtools.py", line 47 in find_gui_and_backend
  File "/home/EU/derossim/pycharm-2018.2.4/helpers/pydev/pydev_ipython/matplotlibtools.py", line 96 in activate_matplotlib
  File "/home/EU/derossim/pycharm-2018.2.4/helpers/pydev/_pydev_bundle/pydev_console_utils.py", line 199 in <lambda>
  File "/home/EU/derossim/pycharm-2018.2.4/helpers/pydev/_pydev_bundle/pydev_import_hook.py", line 23 in do_import
  File "/home/EU/derossim/miniconda3/envs/confidence_prediction/lib/python3.6/site-packages/matplotlib/__init__.py", line 891 in __getitem__
  File "/home/EU/derossim/pycharm-2018.2.4/helpers/pydev/pydev_ipython/matplotlibtools.py", line 47 in find_gui_and_backend
  File "/home/EU/derossim/pycharm-2018.2.4/helpers/pydev/pydev_ipython/matplotlibtools.py", line 96 in activate_matplotlib
  File "/home/EU/derossim/pycharm-2018.2.4/helpers/pydev/_pydev_bundle/pydev_console_utils.py", line 199 in <lambda>
  File "/home/EU/derossim/pycharm-2018.2.4/helpers/pydev/_pydev_bundle/pydev_import_hook.py", line 23 in do_import
  File "/home/EU/derossim/miniconda3/envs/confidence_prediction/lib/python3.6/site-packages/matplotlib/__init__.py", line 891 in __getitem__
  File "/home/EU/derossim/pycharm-2018.2.4/helpers/pydev/pydev_ipython/matplotlibtools.py", line 47 in find_gui_and_backend
  File "/home/EU/derossim/pycharm-2018.2.4/helpers/pydev/pydev_ipython/matplotlibtools.py", line 96 in activate_matplotlib
  File "/home/EU/derossim/pycharm-2018.2.4/helpers/pydev/_pydev_bundle/pydev_console_utils.py", line 199 in <lambda>
  File "/home/EU/derossim/pycharm-2018.2.4/helpers/pydev/_pydev_bundle/pydev_import_hook.py", line 23 in do_import
  File "/home/EU/derossim/miniconda3/envs/confidence_prediction/lib/python3.6/site-packages/matplotlib/__init__.py", line 891 in __getitem__
  File "/home/EU/derossim/pycharm-2018.2.4/helpers/pydev/pydev_ipython/matplotlibtools.py", line 47 in find_gui_and_backend
  File "/home/EU/derossim/pycharm-2018.2.4/helpers/pydev/pydev_ipython/matplotlibtools.py", line 96 in activate_matplotlib
  File "/home/EU/derossim/pycharm-2018.2.4/helpers/pydev/_pydev_bundle/pydev_console_utils.py", line 199 in <lambda>
  File "/home/EU/derossim/pycharm-2018.2.4/helpers/pydev/_pydev_bundle/pydev_import_hook.py", line 23 in do_import
  File "/home/EU/derossim/miniconda3/envs/confidence_prediction/lib/python3.6/site-packages/matplotlib/__init__.py", line 891 in __getitem__
  File "/home/EU/derossim/pycharm-2018.2.4/helpers/pydev/pydev_ipython/matplotlibtools.py", line 47 in find_gui_and_backend
  File "/home/EU/derossim/pycharm-2018.2.4/helpers/pydev/pydev_ipython/matplotlibtools.py", line 96 in activate_matplotlib
  File "/home/EU/derossim/pycharm-2018.2.4/helpers/pydev/_pydev_bundle/pydev_console_utils.py", line 199 in <lambda>
  File "/home/EU/derossim/pycharm-2018.2.4/helpers/pydev/_pydev_bundle/pydev_import_hook.py", line 23 in do_import
  File "/home/EU/derossim/miniconda3/envs/confidence_prediction/lib/python3.6/site-packages/matplotlib/__init__.py", line 891 in __getitem__
  File "/home/EU/derossim/pycharm-2018.2.4/helpers/pydev/pydev_ipython/matplotlibtools.py", line 47 in find_gui_and_backend
  File "/home/EU/derossim/pycharm-2018.2.4/helpers/pydev/pydev_ipython/matplotlibtools.py", line 96 in activate_matplotlib
  File "/home/EU/derossim/pycharm-2018.2.4/helpers/pydev/_pydev_bundle/pydev_console_utils.py", line 199 in <lambda>
  File "/home/EU/derossim/pycharm-2018.2.4/helpers/pydev/_pydev_bundle/pydev_import_hook.py", line 23 in do_import
  File "/home/EU/derossim/miniconda3/envs/confidence_prediction/lib/python3.6/site-packages/matplotlib/__init__.py", line 891 in __getitem__
  File "/home/EU/derossim/pycharm-2018.2.4/helpers/pydev/pydev_ipython/matplotlibtools.py", line 47 in find_gui_and_backend
  ...

Please not that the first part of the error (here repeated 3 times) is actually repeted so many times that the console cannot show me the full error.

Also, if I let the Scientific mode disabled in "View", but I activate the "show plot in tool window", then the error disappears but I am forced to use the tool window and I cannot change the matplotlib backend (currently Qt5Agg).

Please note that, if I open a terminal outside Pycharm and activate the same conda environment, I can import matplotlib without any issue.

Any suggestion is welcome, thank you.

0

Please sign in to leave a comment.