No module named 'kiwisolver' when trying to import matplotlib

Question:

I am trying to plot some data in Python and therefore require matplotlib.
When trying to import it, I get the ModuleNotFoundError.

My line that raises the error is

import matplotlib.pyplot as plt

My installed packages include (according to PyCharm’s Python Interpreter Menu):

matplotlib==3.3.4
numpy==1.20.1
pandas==1.4.3
kiwisolver==1.3.1

The stack trace shows

  File "C:Program FilesJetBrainsPyCharm 2020.3pluginspythonhelperspydev_pydev_bundlepydev_umd.py", line 197, in runfile
    pydev_imports.execfile(filename, global_vars, local_vars)  # execute the script
  File "C:Program FilesJetBrainsPyCharm 2020.3pluginspythonhelperspydev_pydev_imps_pydev_execfile.py", line 18, in execfile
    exec(compile(contents+"n", file, 'exec'), glob, loc)
  File "C:/Users/user/pycharm/ai_ems/data/data_classes/load/electrical/fit_compressor_data.py", line 3, in <module>
    import matplotlib.pyplot as plt
  File "C:Program FilesJetBrainsPyCharm 2020.3pluginspythonhelperspydev_pydev_bundlepydev_import_hook.py", line 21, in do_import
    module = self._system_import(name, *args, **kwargs)
  File "C:Usersuserpycharmai_emsems-gymvenv_ems-gymlibsite-packagesmatplotlib__init__.py", line 174, in <module>
    _check_versions()
  File "C:Usersuserpycharmai_emsems-gymvenv_ems-gymlibsite-packagesmatplotlib__init__.py", line 168, in _check_versions
    module = importlib.import_module(modname)
  File "C:UsersuserAppDataLocalProgramsPythonPython37libimportlib__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
ModuleNotFoundError: No module named 'kiwisolver'
Asked By: naraghi

||

Answers:

After finding this: https://github.com/nucleic/kiwi/issues/68:

I uninstalled and reinstalled kiwisolver, and for some reason it works now.

Answered By: naraghi

Reinstalling Kiwi solver worked for me

Answered By: Vignesh V