Open cYclonEK opened 6 years ago
Hi, weight_as_number()
was deprecated in matplotlib 2.1. I'm trying to develop a workaround by substituting the call to weight_as_number()
in backend_kivy.py
line 669 with an equivalent method that could be implemented completely within backend_kivy.py
. This was weight_as_number()
's implementation:
def weight_as_number(weight): """ Return the weight property as a numeric value. String values are converted to their corresponding numeric value. """ if isinstance(weight, six.string_types): try: weight = weight_dict[weight.lower()] except KeyError: weight = 400 elif weight in range(100, 1000, 100): pass else: raise ValueError('weight not a valid integer') return weight
Ok, so I implemented weight_as_number()
within backend_kivy.py
but it seems like that not the only incompatibility with matplotlib 3.0.0. Running test_plt.py now gives the following error regarding matplotlib's backend_bases.py
script:
`Traceback (most recent call last):
File "C:/Users/CarlosM/PycharmProjects/kivyplt/venv/test_plt.py", line 100, in
Process finished with exit code 1`
Out of curiosity, I changed matplotlib's backend_bases.py
implementation to call cls.mainloop(self)
with the self
argument as suggested by the TypeError
. But this time I got the error: NameError: name 'self' is not defined
.
Any suggestions? Does anybody know more or less how much effort is needed to get the matplotlib Kivy flower to work with matplotlib 3.0.0? Would it be trivial?
By the way, it's still possible to get it to run on a virtual environment by installing matplotlib 2.0.0:
python -m pip install -U --force-reinstall matplotlib==2.0.0
Hello @mcu101 Thank you so much for your effort I am just a beginner on these kivy and matplotlib things Sorry that I cannot provide you more Wish you good luck on this issue
Did https://github.com/kivy-garden/garden.matplotlib/pull/62 fix your issue?
@matham: I'll check it out in the next few days.
@mcu101 pip install 'matplotlib<3.0'
is probably better so you will get the latest version of 2.2.
Did it ever get sorted out if this backend works with mpl >= 3.0?
Try this:
instead of altering kivy.garden code, this one works for me
import matplotlib
matplotlib._png = None
from kivy.garden.matplotlib.backend_kivyagg import FigureCanvasKivyAgg
C:\Users\enzok\AppData\Local\Programs\Python\Python36\python.exe D:/py_projs/every_day_task/test2.py [INFO ] [Logger ] Record log in C:\Users\enzok.kivy\logs\kivy_18-09-20_37.txt [INFO ] [Kivy ] v1.10.1 [INFO ] [Python ] v3.6.1 (v3.6.1:69c0db5, Mar 21 2017, 18:41:36) [MSC v.1900 64 bit (AMD64)] Traceback (most recent call last): File "D:/py_projs/every_day_task/test2.py", line 1, in
from kivy.garden.matplotlib import *
File "C:\Users\enzok\AppData\Local\Programs\Python\Python36\lib\site-packages\kivy\garden__init.py", line 100, in load_module
return self._load_module(fullname, moddir)
File "C:\Users\enzok\AppData\Local\Programs\Python\Python36\lib\site-packages\kivy\garden__init__.py", line 104, in _load_module
('', '', imp.PKG_DIRECTORY))
File "C:\Users\enzok\AppData\Local\Programs\Python\Python36\lib\imp.py", line 244, in load_module
return load_package(name, filename)
File "C:\Users\enzok\AppData\Local\Programs\Python\Python36\lib\imp.py", line 216, in load_package
return _load(spec)
File "C:\Users\enzok.kivy\garden\garden.matplotlib\init__.py", line 1, in
from kivy.garden.matplotlib.backend_kivy import FigureCanvasKivy,\
File "C:\Users\enzok.kivy\garden\garden.matplotlib\backend_kivy.py", line 257, in
from matplotlib.font_manager import weight_as_number
ImportError: cannot import name 'weight_as_number'