Skip to content

matplotlib inline does not work #35

@rlanzafame

Description

@rlanzafame

The IPython console is not working with matplotlib. It's not a generic import, since import numpy as np works. Below the error report from 2 attempts at using it:

import matplotlib as plt

Error:

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
/tmp/xpython_42/2917018121.py in <cell line: 1>()
----> 1 import matplotlib as plt

/tmp/xeus-python-kernel/envs/xeus-python-kernel/lib/python3.10/site-packages/matplotlib/__init__.py in <module>
    206 
    207 
--> 208 _check_versions()
    209 
    210 

/tmp/xeus-python-kernel/envs/xeus-python-kernel/lib/python3.10/site-packages/matplotlib/__init__.py in _check_versions()
    201     ]:
    202         module = importlib.import_module(modname)
--> 203         if parse_version(module.__version__) < parse_version(minver):
    204             raise ImportError(f"Matplotlib requires {modname}>={minver}; "
    205                               f"you have {module.__version__}")

AttributeError: module 'kiwisolver' has no attribute '__version__'
%matplotlib inline

Error:

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
/tmp/xpython_42/352233182.py in <cell line: 1>()
----> 1 get_ipython().run_line_magic('matplotlib', 'inline')

/tmp/xeus-python-kernel/envs/xeus-python-kernel/lib/python3.10/site-packages/IPython/core/interactiveshell.py in run_line_magic(self, magic_name, line, _stack_depth)
   2405                 kwargs['local_ns'] = self.get_local_scope(stack_depth)
   2406             with self.builtin_trap:
-> 2407                 result = fn(*args, **kwargs)
   2408             return result
   2409 

/tmp/xeus-python-kernel/envs/xeus-python-kernel/lib/python3.10/site-packages/decorator.py in fun(*args, **kw)
    230             if not kwsyntax:
    231                 args, kw = fix(args, kw, sig)
--> 232             return caller(func, *(extras + args), **kw)
    233     fun.__name__ = func.__name__
    234     fun.__doc__ = func.__doc__

/tmp/xeus-python-kernel/envs/xeus-python-kernel/lib/python3.10/site-packages/IPython/core/magic.py in <lambda>(f, *a, **k)
    185     # but it's overkill for just that one bit of state.
    186     def magic_deco(arg):
--> 187         call = lambda f, *a, **k: f(*a, **k)
    188 
    189         if callable(arg):

/tmp/xeus-python-kernel/envs/xeus-python-kernel/lib/python3.10/site-packages/IPython/core/magics/pylab.py in matplotlib(self, line)
     97             print("Available matplotlib backends: %s" % backends_list)
     98         else:
---> 99             gui, backend = self.shell.enable_matplotlib(args.gui.lower() if isinstance(args.gui, str) else args.gui)
    100             self._show_matplotlib_backend(args.gui, backend)
    101 

/tmp/xeus-python-kernel/envs/xeus-python-kernel/lib/python3.10/site-packages/IPython/core/interactiveshell.py in enable_matplotlib(self, gui)
   3598         """
   3599         from IPython.core import pylabtools as pt
-> 3600         from matplotlib_inline.backend_inline import configure_inline_support
   3601         gui, backend = pt.find_gui_and_backend(gui, self.pylab_gui_select)
   3602 

/tmp/xeus-python-kernel/envs/xeus-python-kernel/lib/python3.10/site-packages/matplotlib_inline/__init__.py in <module>
----> 1 from . import backend_inline, config  # noqa
      2 __version__ = "0.1.6"  # noqa

/tmp/xeus-python-kernel/envs/xeus-python-kernel/lib/python3.10/site-packages/matplotlib_inline/backend_inline.py in <module>
      4 # Distributed under the terms of the BSD 3-Clause License.
      5 
----> 6 import matplotlib
      7 from matplotlib import colors
      8 from matplotlib.backends import backend_agg

/tmp/xeus-python-kernel/envs/xeus-python-kernel/lib/python3.10/site-packages/matplotlib/__init__.py in <module>
    206 
    207 
--> 208 _check_versions()
    209 
    210 

/tmp/xeus-python-kernel/envs/xeus-python-kernel/lib/python3.10/site-packages/matplotlib/__init__.py in _check_versions()
    201     ]:
    202         module = importlib.import_module(modname)
--> 203         if parse_version(module.__version__) < parse_version(minver):
    204             raise ImportError(f"Matplotlib requires {modname}>={minver}; "
    205                               f"you have {module.__version__}")

AttributeError: module 'kiwisolver' has no attribute '__version__'

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions