matplotlib error - no module named tkinter

后端 未结 16 1723
被撕碎了的回忆
被撕碎了的回忆 2020-11-28 04:10

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

16条回答
  •  一个人的身影
    2020-11-28 04:14

    On Ubuntu, early 2018, there is no python3.6-tk on ubuntu's (xenial/16.04) normal distributions, so even if you have earlier versions of python-tk this won't work.

    My solution was to use set everything up with python 3.5:

     sudo apt install python3.5-tk
     virtualenv --python=`which python3.5` python-env
     source python-env/bin/activate
     pip install -r requirements.txt
    

    And now matplotlib can find tkinter.

    EDIT:

    I just needed 3.6 afterall, and the trick was to:

    sudo apt install tk-dev
    

    and then rebuild python3.6, after tk-dev, eg:

    ./configure
    make
    make install
    

提交回复
热议问题