1

I tried to install matplotlib using pip install matplotlib and it retuned the following error. For reference I am using windows 7.

Removing temporary dir c:\users\user\appdata\local\temp\pip_build_RTRA...
Command C:\python27\python.exe -c "import setuptools;__file__='c:\\users\\user\\appdata\\local\\temp\\pip_build_USER\\matplotlib\\setup.py';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record c:\users\user\appdata\local\temp\pip-yplfpm-record\install-record.txt --single-version-externally-managed failed with error code 1 in c:\users\user\appdata\local\temp\pip_build_USER\matplotlib

Exception information:
Traceback (most recent call last):
  File "C:\python27\lib\site-packages\pip-1.4.1-py2.7.egg\pip\basecommand.py", line 134, in main
    status = self.run(options, args)
  File "C:\python27\lib\site-packages\pip-1.4.1-py2.7.egg\pip\commands\install.py", line 241, in run
    requirement_set.install(install_options, global_options, root=options.root_path)
  File "C:\python27\lib\site-packages\pip-1.4.1-py2.7.egg\pip\req.py", line 1298, in install
    requirement.install(install_options, global_options, *args, **kwargs)
  File "C:\python27\lib\site-packages\pip-1.4.1-py2.7.egg\pip\req.py", line 625, in install
    cwd=self.source_dir, filter_stdout=self._filter_install, show_stdout=False)
  File "C:\python27\lib\site-packages\pip-1.4.1-py2.7.egg\pip\util.py", line 670, in call_subprocess
    % (command_desc, proc.returncode, cwd))
InstallationError: Command C:\python27\python.exe -c "import setuptools;__file__='c:\\users\\user\\appdata\\local\\temp\\pip_build_USER\\matplotlib\\setup.py';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record c:\users\user\appdata\local\temp\pip-yplfpm-record\install-record.txt --single-version-externally-managed failed with error code 1 in c:\users\user\appdata\local\temp\pip_build_USER\matplotlib

To try and get around this error we tried to install using the following download: https://pypi.python.org/pypi/matplotlib/1.3.0

The installer returned the following details then dissapeared of screen.

BUILDING MATPLOTLIB
            matplotlib: yes [1.3.0]
                python: yes [2.7.5 (default, May 15 2013, 22:43:36) [MSC
                        v.1500 32 bit (Intel)]]
              platform: yes [win32]

REQUIRED DEPENDENCIES AND EXTENSIONS
                 numpy: yes [version 1.7.1]
              dateutil: yes [dateutil was not found. It is required for date
                        axis support. pip/easy_install may attempt to
                        install it after matplotlib.]
               tornado: yes [tornado was not found. It is required for the
                        WebAgg backend. pip/easy_install may attempt to
                        install it after matplotlib.]
             pyparsing: yes [pyparsing was not found. It is required for
                        mathtext support. pip/easy_install may attempt to
                        install it after matplotlib.]
                 pycxx: yes [Couldn't import.  Using local copy.]
                libagg: yes [pkg-config information for 'libagg' could not
                        be found. Using local copy.]
              freetype: yes [Unknown version]
                   png: yes [pkg-config information for 'libpng' could not
                        be found. Using unknown version.]

OPTIONAL SUBPACKAGES
           sample_data: yes [installing]
              toolkits: yes [installing]
                 tests: yes [nose 0.11.1 or later is required to run the
                        matplotlib test suite]

OPTIONAL BACKEND EXTENSIONS
                macosx: no  [Mac OS-X only]
                qt4agg: no  [PyQt4 not found]
               gtk3agg: no  [Requires pygobject to be installed.]
             gtk3cairo: no  [Requires cairo to be installed.]
                gtkagg: no  [Requires pygtk]
                 tkagg: no  [The C/C++ header for Tk (tk.h) could not be
                        found.  You may need to install the development
                        package.]
                 wxagg: no  [requires wxPython]
                   gtk: no  [Requires pygtk]
                   agg: yes [installing]
                 cairo: no  [cairo not found]
             windowing: yes [installing]

OPTIONAL LATEX DEPENDENCIES
                dvipng: yes [version file.]
           ghostscript: yes [version 'gswin32c' is not recognized as an
                        internal or external command,  operable program or
                        batch file. ]
                 latex: no
               pdftops: no

We assumed it had installed correctly as we didn't see an error, so we tried the following example code:

import matplotlib.pyplot as plt
#import numpy as np
plt.plot([1,2,3,4],[4,7,9,12])
plt.show()

It unfortunately returned the following traceback:

Traceback (most recent call last):
File "C:\matplotlib_test.py", line 1, in <module>
    import matplotlib.pyplot as plt
ImportError: No module named matplotlib.pyplot

Does anyone know to get this working correctly?

AEA
  • 213
  • 2
  • 12
  • 34
  • Does `import matplotlib` not work either? I always found this difficult; I ended up using the [free EDP installation](https://www.enthought.com/products/epd/free/) (overwriting my entire Python build). It includes Numpy and other libraries that are needed to get things to work, and saved a bunch of effort. – Floris Oct 01 '13 at 22:37
  • @floris I have tried `import matplotlib` instead and it returns `ImportError: No module named matplotlib` :( – AEA Oct 01 '13 at 22:40
  • Your module cannot be found by Python, most probably it is not installed, in fact. – mguijarr Oct 01 '13 at 22:50
  • @mguijarr Any idea for the reason that it would be failing to install then? I attempted to install both manually and via pip & easy install – AEA Oct 01 '13 at 22:53
  • 1
    You're on Windows? You can try to install Python and matplotlib with a Python distribution like Python(x,y), this is far easier: http://code.google.com/p/pythonxy/ – mguijarr Oct 01 '13 at 22:56
  • Hello yes I am on windows, I should have added that too my question, will edit accordingly – AEA Oct 01 '13 at 22:58
  • enthought canopy or continium's anaconda might also be good to look into. – tacaswell Oct 02 '13 at 07:37
  • enthought did enable me to produce a graph however I really do need to be able to get matplotlib working in the native python application – AEA Oct 02 '13 at 22:51

2 Answers2

5

matplotlib requires dateutil,pyparsing and numpy packages to run. Do a pip install python-dateutil and pip install pyparsing also install numpy if you don't have it. After all these dependencies are installed, matplotlib should work.

If you look at your installer's message you can see the list of dependencies:

REQUIRED DEPENDENCIES AND EXTENSIONS
                 numpy: yes [version 1.7.1]
              dateutil: yes [dateutil was not found. It is required for date
                        axis support. pip/easy_install may attempt to
                        install it after matplotlib.]
               tornado: yes [tornado was not found. It is required for the
                        WebAgg backend. pip/easy_install may attempt to
                        install it after matplotlib.]
             pyparsing: yes [pyparsing was not found. It is required for
                        mathtext support. pip/easy_install may attempt to
                        install it after matplotlib.]
                 pycxx: yes [Couldn't import.  Using local copy.]
                libagg: yes [pkg-config information for 'libagg' could not
                        be found. Using local copy.]
              freetype: yes [Unknown version]
                   png: yes [pkg-config information for 'libpng' could not
                        be found. Using unknown version.]
Cola
  • 2,097
  • 4
  • 24
  • 30
0

I had the same issue so I completely uninstalled python and then reinstalled it as part of the PythonXY package available to download here: https://code.google.com/p/pythonxy/

Hope this helps and good luck with matplotlib :)

Ryflex
  • 5,559
  • 25
  • 79
  • 148