How to install python-matplotlib in ubuntu 12.04?

折月煮酒 提交于 2019-12-21 02:05:42

问题


When I tried

$ sudo apt-get install python-matplotlib

I got the following error:

Reading package lists... Done
Building dependency tree       
Reading state information... Done
E: Unable to locate package python-matplotlib

How to install it?


回答1:


One "cleaner" way to install matplotlib is to go through pip:

sudo apt-get install python-pip
sudo pip install matplotlib

It will also ensure that you'll get the most up to date stable version and will be easier to maintain when an upgrade is pushed to pypi.

If the build process complains about missing headers files just install the missing lib with:

sudo apt-get install libfreetype6-dev libpng-dev

Warning: it can take a lot of time to fully build as one dependency of matplotlib is numpy which is quite a project in terms of c extension.




回答2:


type the following commands in terminal:

$ wget https://github.com/matplotlib/matplotlib/zipball/master
$ unzip master
$ cd matplotlib-matplotlib-bb3ea55
$ sudo python2.7 setup.py build
$ sudo python2.7 setup.py install

If the unzip command doesn't work properly, extract the files manually. $ cd matplotlib-matplotlib-bb3ea55 should be the proper directory (however the last seven characters may be different).




回答3:


Also, make sure you have python-dev package.

If not, run:

sudo apt-get install python-dev


来源:https://stackoverflow.com/questions/21646179/how-to-install-python-matplotlib-in-ubuntu-12-04

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