12

I want to use matplotlib instead kivy_garden.graph. Actually, I tried this code to check if it works for me. I've had some problems with installing matplotlib but I have successfully(or not) done that.

When I started the code I got from matplotlib import _png ImportError: cannot import name '_png' from 'matplotlib' (D:\PyCharmProjects\kivyApp\venv\lib\site-packages\matplotlib\__init__.py) I reinstalled matplotlib and pip, tried another version of matplotlib and I don't know why it is not working for me. I have Python 3.7.5, pip 20.2.4 and matplotlib 3.3.3

Sylvaus
  • 816
  • 5
  • 13
WASP-21b
  • 137
  • 1
  • 1
  • 7

5 Answers5

17

Reverting to matplotlib version 3.0.2 didn't work for me, but with 3.1.3 it did.

python -m pip uninstall matplotlib
pip install matplotlib==3.1.3

Python 3.8.2

Diego BM
  • 179
  • 1
  • 5
  • 1
    What kind of solution is this? A proper answer requires a solution that works for the most current stable version of matplotlib. – Martin Jul 13 '21 at 12:34
2

I was having this problem in Google Colab and couldn't solve it. The simple solution that I found was to install the stable version that is pip install -U matplotlib and restarted the runtime and it worked.

S.B
  • 7,457
  • 5
  • 15
  • 37
1

It's work now. I executed py -m pip uninstall matplotlib and after py -m pip install matplotlib --version=3.0.2 from terminal in PyCharm. The same commands in cmd and git bash didn't work.

WASP-21b
  • 137
  • 1
  • 1
  • 7
0

If you are using a linux distribution the problem is in the installation of matplotlib.

uninstall the current version: pip uninstall matplotlib

The correct installation can be found at: https://matplotlib.org/stable/users/installing.html

Choose the correct code for your distribution from below:

Linux package manager If you are using the Python version that comes with your Linux distribution, you can install Matplotlib via your package manager, e.g.:

Debian / Ubuntu: sudo apt-get install python3-matplotlib

Fedora: sudo dnf install python3-matplotlib

Red Hat: sudo yum install python3-matplotlib

Arch: sudo pacman -S python-matplotlib

after this it should work fine.

0

You also can coment line where this import is :) (for me it is C:\Users\{username}\.kivy\garden\garden.matplotlib\backend_kivy.py , line 256) But i dont know what problems it can bring in the future.

User
  • 1
  • That seems like an unsafe hack to me, though still an interesting one to document. Does your code using this library still work after having done this? – joanis Sep 29 '21 at 12:59