Not able to plot graph: matplotlib is needed for plotting

拜拜、爱过 提交于 2019-12-01 17:45:42
Thomas Orozco

You need to install matplotlib, as instructed (this error in thrown by mprof when it can't find matplotlib).

You can do so using pip pip install matplotlib (you might need to prefix this with sudo) or your package manager:

  • sudo apt-get install -y python-matplotlib on Debian, Ubuntu and derivatives.
  • sudo yum install -y python-matplotlib on RHEL, CentOS and derivatives.

It seems matplotlib: 3.0.1 does not go well with python 3.7 in conda environment. df.plot() command could not be executed properly showing "ImportError: matplotlib is required for plotting" but actually matplotlib is installed.

I tried to downgrade matplotlib to 3.0.0 then everything is fine.

conda install -n [your_conda_envionment] matplotlib==3.0.0

I had the same problem. I used memory_profiler lib typing this commands (mprof run runner.py and mprof plot) and got a message "matplotlib is needed for plotting"

I tried to get rid of this problem following advice I found here but in the result I solved this problem completing these simple steps:

  1. delete files in /usr/lib64/python2.7/site-packages/ connected with matplotlib (or you can uninstall matplotlib using the ordinary way)

  2. use sudo yum-builddep python-matplotlib to install connected packages (222 packages were installed, if you need apt-get, you need this command: sudo apt-get build-dep python-matplotlib)

  3. install matplotlib sudo yum reinstall python-matplotlib (or use install command, with apt-get: sudo apt-get install python-matplotlib)

I believe this will help.

I had same problem on freshely installed Ubuntu 16.04. To solve it, I have installed SciPy like this: sudo pip install scipy

Also I had to install tkinter lib like this: sudo apt-get install python-tk

I guess somewhere in the past, matplotlib had scipy as dependency, but now it only has numpy, while mprof plot requires scipy.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!