I tried to use the matplotlib package via Pycharm IDE on windows 10. when I run this code:
from matplotlib import pyplot
I get the followin
I had the same issue on Win x86/64 because my custom Python3.7 installation did not include Tcl packages, so just modify or re-install your python
https://www.python.org/downloads/release/python-370/
you can use
import matplotlib
matplotlib.use('agg')
import matplotlib.pyplot as plt
if you dont want to use tkinter
at all.
Also dont forget to use %matplotlib inline
at the top of your notebook if using one.
EDIT: agg
is a different backend like tkinter
for matplotlib.
For Windows users, there's no need to download the installer again. Just do the following:
Wait for installation and you're done.
If you are using python 3.6, this worked for me:
sudo apt-get install python3.6-tk
instead of
sudo apt-get install python3-tk
Which works for other versions of python3
Sometimes (for example in osgeo4w distribution) tkinter is removed.
Try changing matplotlib backend editing matplotlibrc file located in [python install dir]/matplotlib/mpl-data/matplotlibrc
changing The backend parameter from backend: TkAgg
to something other like backend: Qt4Agg
as described here: http://matplotlib.org/faq/usage_faq.html#what-is-a-backend
If you are using fedora then first install tkinter
sudo dnf install python3-tkinter
I don't think you need to import tkinter afterwards I also suggest you to use virtualenv
$ python3 -m venv myvenv
$ source myvenv/bin/activate
And add the necessary packages using pip