无法在 Python 3 中导入 matplotlib

Cannot import matplotlib in Python 3

我想在 windows 上安装 matplotlib。为此,我尝试了这些行,

git clone https://github.com/matplotlib/matplotlib
cd matplotlib
py setup.py build
py setup.py install

我在 this link

找到的

但是我认为安装没有成功。这是 py setup.py install:

的结果

所以仍然跟随导入不起作用;

import matplotlib.pyplot as plt
import matplotlib.animation as animation

一个错误说未解决的导入。所以我假设这是因为没有安装 freetype 和 png。

现在我找到了 freetype.dll 并安装了它,但是我应该把那个文件放在哪里?

关于这个问题的任何想法。

是的。 Matplotlib 有一些依赖项,需要安装这些依赖项才能使库充分发挥作用。 Quoting:

Once you have satisfied the requirements detailed below (mainly python, numpy, libpng and freetype), you can build matplotlib:

cd matplotlib python setup.py build python setup.py install

为确保程序正确,请检查 build instructions。如果这个过程看起来有些复杂(有时是),您可以考虑 Python 分布,例如:

1) WinPython

2) Python XY

3) Anaconda

,默认情况下已经带了几个库,使使用 Python(和扩展)更容易。