Matplotlib doesn't display graph in virtualenv

后端 未结 5 883
予麋鹿
予麋鹿 2021-02-05 11:53

I have pip installed matplotlib in my virtualenv and I am trying to plot a simple graph. I use Eclipse and PyDev. When I run the script from Eclipse it doesn\'t display any grap

5条回答
  •  青春惊慌失措
    2021-02-05 12:29

    First off, you might want to check out:

    http://matplotlib.org/faq/installing_faq.html#matplotlib-compiled-fine-but-nothing-shows-up-when-i-use-it

    To see what's going wrong, check out the matplotlib using git instead of either pip or easy_install. We're going to do a more manual install:

    git clone git@github.com:matplotlib/matplotlib.git
    cd matplotlib
    python setup.py
    

    This will print out the configuration of what pip or easy_install would have done. Look through the "OPTIONAL BACKEND DEPENDENCIES" and make sure that some of the ones that produce windows are enabled (Tkinter, Gtk+, Mac OS X native, Qt, Cairo, etc.). If you see that none of these are available, then you need to install some of these libraries for your operating system before you continue installing matplotlib.

    After installing say, Tk (on ubuntu: sudo apt-get install tcl-dev tk-dev), then when you re-run

    python setup.py
    

    you will see that the Tk backend is enabled. Proceeding with

    python setup.py build && python setup.py install
    

    should get you up and running... but at that point you might even just delete the whole git clone directory and go back to installing with pip.

提交回复
热议问题