在Windows 10 64位中安装Matplotlib

时间:2017-05-17 23:40:27

标签: python python-2.7 numpy matplotlib

有人能告诉我应该下载哪些文件以及我必须在命令行中执行哪些语句才能安装Matplotlib?

我在Windows 10 64位上有Python 2.7.13 这些是我解压缩的文件:
enter image description here

全部从以下网址下载:http://www.lfd.uci.edu/~gohlke/pythonlibs/#numpy

我执行的命令:

python -m pip install -U pip setuptools
python -m pip install matplotlib

python -m pip install -U pip

在检查是否安装了Numpy和Matplotlib时,我收到了这两个错误。

>>> import numpy

**Traceback (most recent call last):
  File "<pyshell#3>", line 1, in <module>
    import numpy
  File "numpy\__init__.py", line 142, in <module>
    from . import add_newdocs
  File "numpy\add_newdocs.py", line 13, in <module>
    from numpy.lib import add_newdoc
   File "numpy\lib\__init__.py", line 8, in <module>
    from .type_check import *
  File "numpy\lib\type_check.py", line 11, in <module>
    import numpy.core.numeric as _nx
  File "numpy\core\__init__.py", line 26, in <module>
    raise ImportError(msg)
ImportError: 
Importing the multiarray numpy extension module failed.  Most
likely you are trying to import a failed build of numpy.
If you're working with a numpy git repo, try `git clean -xdf` (removes   all
files not under version control).  Otherwise reinstall numpy.
Original error was: DLL load failed: %1 no es una aplicación Win32     válida.**

>>> import matplotlib

Traceback (most recent call last):
  File "<pyshell#4>", line 1, in <module>
    import matplotlib
  File "matplotlib\__init__.py", line 122, in <module>
    from matplotlib.cbook import is_string_like, mplDeprecation, dedent,     get_label
  File "matplotlib\cbook.py", line 33, in <module>
import numpy as np
  File "numpy\__init__.py", line 142, in <module>
    from . import add_newdocs
  File "numpy\add_newdocs.py", line 13, in <module>
    from numpy.lib import add_newdoc
  File "numpy\lib\__init__.py", line 8, in <module>
    from .type_check import *
  File "numpy\lib\type_check.py", line 11, in <module>
    import numpy.core.numeric as _nx
  File "numpy\core\__init__.py", line 26, in <module>
    raise ImportError(msg)
ImportError: 
Importing the multiarray numpy extension module failed.  Most
likely you are trying to import a failed build of numpy.
If you're working with a numpy git repo, try `git clean -xdf` (removes     all
files not under version control).  Otherwise reinstall numpy.

Original error was: DLL load failed: %1 no es una aplicación Win32     válida.

2 个答案:

答案 0 :(得分:0)

这是common issue for windows users。并且您可能还需要一些其他库的预编译包,例如SciPy的。

你会在SourceForge找到名称结构为 numpy-X.X.X-win32-superpack-python2.7.exe 的numpy superpack,例如: numpy-1.9.2-win32-superpack-python2.7

Pypi(Python包索引)上,您将找到matplotlib库,其名称结构为 matplotlib-XXXwin32-py2.7.exe ,例如matplotlib-1.4.3.win32-py2.7.exe

答案 1 :(得分:0)

通过自动从python索引下载文件来安装matplotlib,因为你试图在这里做的很可能会失败。

有两个主要选项:

  1. 安装完整的发行版,如Anaconda,Canopy,WinPython等,已经包含了所有相应的库。

  2. 使用预编译的轮子。 Christoph Gohlke确实是this site的来源。然后,您需要确保先安装所有依赖项,然后再安装matplotlib。从numpy开始是最好的,然后是其他依赖项,matplotlib最后。要安装那些使用

    pip install <filename of wheel>
    

    e.g。

    pip install numpy‑1.13.0rc1+mkl‑cp27‑cp27m‑win_amd64.whl