0

Could anyone tell me what files I should download and which statements I must execute in the command line to install Matplotlib?

I have Python 2.7.13 on Windows 10 64 bit.
These are the files I unzipped:
enter image description here

All downloaded from: http://www.lfd.uci.edu/~gohlke/pythonlibs/#numpy

Commands I executed:

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

python -m pip install -U pip

I am getting these two errors when checking if Numpy and Matplotlib are installed.

>>> 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.
Nisse Engström
  • 4,738
  • 23
  • 27
  • 42
Edu Fer
  • 13
  • 1
  • 1
  • 4
  • the error doesn't seem to come from `matplotlib` but rather the error message suggests "`Most likely you are trying to import a failed build of numpy.`". Have you installed `numpy`? – chickity china chinese chicken May 17 '17 at 23:54
  • 1
    @cgohlke The strategy you describe has never worked for me. It is therefore great to have the precompiled packages available on your site for manual download; I use them for every library update available. – ImportanceOfBeingErnest May 19 '17 at 13:31
  • 1
    @cgohlke This may not be the best place to discuss this, but to give an example: This morning I updated matplotlib from version 2.0.0 to 2.0.2. This version needs a newer version of numpy than I had previously. So during the matplotlib install with pip it collected numpy 1.12 and installed it. After that nothing was working anymore. What I needed to do is download the respective wheels from your site, install numpy wheel and then matplotlib wheel and now everything works fine. So for some reason pip did not collect the correct numpy version, thus it's good to have the wheels available. – ImportanceOfBeingErnest May 20 '17 at 13:25

2 Answers2

0

This is a common issue for windows users. And you will probably need precompiled packages for some other libraries as well, e.g. scipy.

You will find on SourceForge the numpy superpack whose name structure is numpy-X.X.X-win32-superpack-python2.7.exe, e.g. numpy-1.9.2-win32-superpack-python2.7.

On Pypi (Python Package Index), you will find the matplotlib library, whose name structure is matplotlib-X.X.X.win32-py2.7.exe, e.g matplotlib-1.4.3.win32-py2.7.exe.

keepAlive
  • 6,369
  • 5
  • 24
  • 39
  • 1
    I am curious of this -1. I would be glad to know why since ***this works (tested in Windows10 64 bits) and adresses the question***. – keepAlive May 19 '17 at 13:08
  • I think someone just downvoted all the answers and the question for no obvious reason. That can happen, don't spend too much time thinking about it. Btw. I did not upvote yours because the question already tells us that he has all the packages available (thus no reason to downvote, but also not exactly a very good answer either). – ImportanceOfBeingErnest May 19 '17 at 13:19
0

Installing matplotlib through pip by automatically downloading the files from the python index as you're trying to do here will most probably fail for windows.

There are two main options:

  1. Install a complete distribution like Anaconda, Canopy, WinPython, etc. which already has all the respective libraries included.

  2. Use precompiled wheels. A source for those is indeed this site by Christoph Gohlke. You would then need to make sure to install all dependencies first and matplotlib last. Starting with numpy is the best, then other dependencies, matplotlib last. To install those use

    pip install <filename of wheel>
    

    e.g.

    pip install numpy‑1.13.0rc1+mkl‑cp27‑cp27m‑win_amd64.whl
    
ImportanceOfBeingErnest
  • 321,279
  • 53
  • 665
  • 712