安装matplotlib

1.1 Linux中安装matplotlib
  • 如果使用的系统自带的python版本,可使用系统的包管理器安装matplotlib,命令如下:
$ sudo apt-get install python3-matplotlib
  • 如果使用python2.7,命令如下:
$ sudo apt-get install python-matplotlib
  • 如果安装了较新的python版本,就必须安装matplotlib依赖的一些库:
$ sudo apt-get install python3.5-dev python3.5-tk tk-dev
$ sudo apt-get install libfreetype-dev g++
  • 再使用pip来安装matplotlib:
pip install --user matplotlib
1.2 在OS X系统中安装matplotlib
  • Apple的标准python安装自带matplotlib。如果没有,且python是使用homebrew安装的,可使用命令安装matplotlib:
$ pip install --user matplotlib

备注:安装包时可能需要使用pip3。另外,如果这个命令不能用,删除标志--user。

1.3 在windows中安装matplotlib
  • 先安装Visual studio,地址:https://dev.windows.com,下载Visual Studio Community。
  • 下载matplotlib,地址:https://pypi.python.org/pypi/matplotlib/,下载与你使用的python版本匹配的wheel文件(扩展名为.whl的文件)。例如:python3.5,则需要下载matplotlib-1.4.3-cp35-none-win32.whl。
  • 将.whl文件复制到项目文件夹,在该文件夹下打开命令窗口(在文件夹下按住Shift键-右键-打开cmd窗口),使用pip安装matplotlib:
> cd python_work
python_work> python -m pip install --user matplotlib-1.4.3-cp35-none-win32.whl
1.4 测试matplotlib
$ python3
>>> import matplotlib
>>>

如果没有出现任何错误信息,就说明你安装了matplotlib。

1.5 matplotlib画廊
上一篇:javascript闭包函数


下一篇:2016"百度之星" - 初赛(Astar Round2A)All X(数学 矩阵)