I am using xlwings for running a macro from Excel to plot histogram using python matplotlib but I get the following error when trying to run the python code to plot the histogram from excel:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "c:\users\adel.moustafa\dashboard\main.py", line 7, in <module>
from Modules import Plotter
File "c:\users\adel.moustafa\dashboard\Modules\Plotter.py", line 6, in <module>
import matplotlib.pyplot as plt
File "C:\Users\adel.moustafa\AppData\Local\Programs\Python\Python311\Lib\site-packages\matplotlib\__init__.py", line 887, in <module>
cbook._get_data_path("matplotlibrc"),
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\adel.moustafa\AppData\Local\Programs\Python\Python311\Lib\site-packages\matplotlib\cbook\__init__.py", line 559, in _get_data_path
return Path(matplotlib.get_data_path(), *args)
^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: module 'matplotlib' has no attribute 'get_data_path'
This only happens when I try to run the python code from excel using macro, however if run the same code from Pycharm IDE it works fine and no error is produced.
I have looked for this error and what it means and reach the conclusion of that the error source may be due to conflict of matplotlib versions (one installed using conda and the other using pip). so I have completely removed install anaconda distribution using this guide after that I uninstall and reinstall matplotlib using pip but unfortunately that did not solve the problem. so, I continue to search and found similar posts to my case that advice by using a python virtual environment to solve the problem. so, I have done that but also with no result. finally I completely removed python from my system and reinstalled it but that did not solve the problem either. now, I really don't know what else to do or try!. so if any one could help it would much appreciated.
here is the list of packages installed on my machine
Package Version
--------------- --------
contourpy 1.0.7
cycler 0.11.0
fonttools 4.38.0
kiwisolver 1.4.4
matplotlib 3.6.3
numpy 1.24.1
packaging 23.0
pandas 1.5.3
Pillow 9.4.0
pip 22.3.1
pyparsing 3.0.9
python-dateutil 2.8.2
pytz 2022.7.1
pywin32 305
seaborn 0.12.2
setuptools 65.6.3
six 1.16.0
wheel 0.38.4
xlwings 0.28.9
and the python version
Python 3.11.1
finally here is the posts that I looked at.