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 Files\JetBrains\PyCharm 2020.3\plugins\python\helpers\pydev\_pydev_bundle\pydev_umd.py", line 197, in runfile
pydev_imports.execfile(filename, global_vars, local_vars) # execute the script
File "C:\Program Files\JetBrains\PyCharm 2020.3\plugins\python\helpers\pydev\_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 Files\JetBrains\PyCharm 2020.3\plugins\python\helpers\pydev\_pydev_bundle\pydev_import_hook.py", line 21, in do_import
module = self._system_import(name, *args, **kwargs)
File "C:\Users\user\pycharm\ai_ems\ems-gym\venv_ems-gym\lib\site-packages\matplotlib\__init__.py", line 174, in <module>
_check_versions()
File "C:\Users\user\pycharm\ai_ems\ems-gym\venv_ems-gym\lib\site-packages\matplotlib\__init__.py", line 168, in _check_versions
module = importlib.import_module(modname)
File "C:\Users\user\AppData\Local\Programs\Python\Python37\lib\importlib\__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
ModuleNotFoundError: No module named 'kiwisolver'
After finding this: https://github.com/nucleic/kiwi/issues/68:
I uninstalled and reinstalled kiwisolver, and for some reason it works now.