Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialGuy Lorshbaugh
Python Development Techdegree Graduate 10,892 PointsProblem installing matplotlib.
I'm getting an error installing matplotlib 2.2.2 through PowerShell. I'm using Windows 10, Python version 3.8.3. If there's any help to be had I'd love it, thanks!!
This is the very long error report that PowerShell returned:
PS C:\users\guylo\desktop> pipenv install matplotlib==2.2.2
Creating a virtualenv for this project…
Pipfile: C:\users\guylo\desktop\Pipfile
Using C:/Users/guylo/AppData/Local/Programs/Python/Python38-32/python.exe (3.8.3) to create virtualenv…
[ ==] Creating virtual environment...created virtual environment CPython3.8.3.final.0-32 in 386ms
creator CPython3Windows(dest=C:\Users\guylo\.virtualenvs\desktop-3fcGtUnN, clear=False, global=False)
seeder FromAppData(download=False, pip=bundle, setuptools=bundle, wheel=bundle, via=copy, app_data_dir=C:\Users\guylo\AppData\Local\pypa\virtualenv)
added seed packages: pip==20.2.2, setuptools==49.6.0, wheel==0.35.1
activators BashActivator,BatchActivator,FishActivator,PowerShellActivator,PythonActivator,XonshActivator
Successfully created virtual environment!
Virtualenv location: C:\Users\guylo\.virtualenvs\desktop-3fcGtUnN
Creating a Pipfile for this project…
Installing matplotlib==2.2.2…
Error: An error occurred while installing matplotlib==2.2.2!
Error text: Collecting matplotlib==2.2.2
Using cached matplotlib-2.2.2.tar.gz (37.3 MB)
ERROR: Command errored out with exit status 1:
command: 'C:\Users\guylo\.virtualenvs\desktop-3fcGtUnN\Scripts\python.exe' -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\guylo\\AppData\\Local\\Temp\\pip-install-qoyyit2b\\matplotlib\\setup.py'"'"'; __file__='"'"'C:\\Users\\guylo\\AppData\\Local\\Temp\\pip-install-qoyyit2b\\matplotlib\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base 'C:\Users\guylo\AppData\Local\Temp\pip-pip-egg-info-acq95m_9'
cwd: C:\Users\guylo\AppData\Local\Temp\pip-install-qoyyit2b\matplotlib\
Complete output (61 lines):
============================================================================
Edit setup.cfg to change the build options
BUILDING MATPLOTLIB
matplotlib: yes [2.2.2]
python: yes [3.8.3 (tags/v3.8.3:6f8c832, May 13 2020,
22:20:19) [MSC v.1925 32 bit (Intel)]]
platform: yes [win32]
REQUIRED DEPENDENCIES AND EXTENSIONS
numpy: yes [not found. pip may install it below.]
install_requires: yes [handled by setuptools]
libagg: yes [pkg-config information for 'libagg' could not
be found. Using local copy.]
freetype: no [The C/C++ header for freetype
(freetype2\ft2build.h) could not be found. You may
need to install the development package.]
png: no [The C/C++ header for png (png.h) could not be
found. You may need to install the development
package.]
qhull: yes [pkg-config information for 'libqhull' could not
be found. Using local copy.]
OPTIONAL SUBPACKAGES
sample_data: yes [installing]
toolkits: yes [installing]
tests: no [skipping due to configuration]
toolkits_tests: no [skipping due to configuration]
OPTIONAL BACKEND EXTENSIONS
macosx: no [Mac OS-X only]
qt5agg: no [PySide2 not found; PyQt5 not found]
qt4agg: no [PySide not found; PyQt4 not found]
gtk3agg: no [Requires pygobject to be installed.]
gtk3cairo: no [Requires cairocffi or pycairo to be installed.]
gtkagg: no [Requires pygtk]
tkagg: yes [installing; run-time loading from Python Tcl /
Tk]
wxagg: no [requires wxPython]
gtk: no [Requires pygtk]
agg: yes [installing]
cairo: no [cairocffi or pycairo not found]
windowing: yes [installing]
OPTIONAL LATEX DEPENDENCIES
dvipng: no
ghostscript: no
latex: no
pdftops: no
OPTIONAL PACKAGE DATA
dlls: no [skipping due to configuration]
============================================================================
* The following required packages can not be built:
* freetype, png
* Please check http://gnuwin32.sourceforge.net/packa
* ges/freetype.htm for instructions to install
* freetype
* Please check http://gnuwin32.sourceforge.net/packa
* ges/libpng.htm for instructions to install png
----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
This is likely caused by a bug in matplotlib. Report this to its maintainers.
2 Answers
Jeff Muday
Treehouse Moderator 28,722 PointsSorry, did not see this question until this morning-- I was able to reproduce your problem!!
The short answer is don't install this specific version of matplotlib with the version of Python you have, but install the most current version from the repository that matches up with the Python you are using. Matplotlib 3.1.3 (and its dependencies) should be fully compatible with Python 3.8.3 on Windows 10.
PS C:\Users\jeff> .\testenv\Scripts\activate
(testenv) PS C:\Users\jeff> pip install matplotlib
MatplotLib has a huge number of dependecies and specific version of tools, so you would have to uninstall the current version of Python "setuptools" library and install an earlier version of setuptools that matches to matplotlib 2.2.2.
Too much work, in my opinion!
BELOW, I reproduced your error. In a "pristine" virtual environment of Python 3.8
PS C:\Users\jeff> .\testenv\Scripts\activate
(testenv) PS C:\Users\jeff> pip install matplotlib==2.2.2
Collecting matplotlib==2.2.2
Downloading matplotlib-2.2.2.tar.gz (37.3 MB)
|████████████████████████████████| 37.3 MB 2.2 MB/s
ERROR: Command errored out with exit status 1:
command: 'C:\Users\jeff\testenv\Scripts\python.exe' -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\jeff\\AppData\\Local\\Temp\\pip-install-6vtzvs3l\\matplotlib\\setup.py'"'"'; __file__='"'"'C:\\Users\\jeff\\AppData\\Local\\Temp\\pip-install-6vtzvs3l\\matplotlib\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base 'C:\Users\jeff\AppData\Local\Temp\pip-pip-egg-info-m4egguly'
cwd: C:\Users\jeff\AppData\Local\Temp\pip-install-6vtzvs3l\matplotlib\
Complete output (61 lines):
============================================================================
Edit setup.cfg to change the build options
BUILDING MATPLOTLIB
matplotlib: yes [2.2.2]
python: yes [3.8.2 (tags/v3.8.2:7b3ab59, Feb 25 2020,
23:03:10) [MSC v.1916 64 bit (AMD64)]]
platform: yes [win32]
REQUIRED DEPENDENCIES AND EXTENSIONS
numpy: yes [not found. pip may install it below.]
install_requires: yes [handled by setuptools]
libagg: yes [pkg-config information for 'libagg' could not
be found. Using local copy.]
freetype: no [The C/C++ header for freetype
(freetype2\ft2build.h) could not be found. You may
need to install the development package.]
png: no [The C/C++ header for png (png.h) could not be
found. You may need to install the development
package.]
qhull: yes [pkg-config information for 'libqhull' could not
be found. Using local copy.]
OPTIONAL SUBPACKAGES
sample_data: yes [installing]
toolkits: yes [installing]
tests: no [skipping due to configuration]
toolkits_tests: no [skipping due to configuration]
OPTIONAL BACKEND EXTENSIONS
macosx: no [Mac OS-X only]
qt5agg: no [PySide2 not found; PyQt5 not found]
qt4agg: no [PySide not found; PyQt4 not found]
gtk3agg: no [Requires pygobject to be installed.]
gtk3cairo: no [Requires cairocffi or pycairo to be installed.]
gtkagg: no [Requires pygtk]
tkagg: yes [installing; run-time loading from Python Tcl /
Tk]
wxagg: no [requires wxPython]
gtk: no [Requires pygtk]
agg: yes [installing]
cairo: no [cairocffi or pycairo not found]
windowing: yes [installing]
OPTIONAL LATEX DEPENDENCIES
dvipng: no
ghostscript: no
latex: no
pdftops: no
OPTIONAL PACKAGE DATA
dlls: no [skipping due to configuration]
============================================================================
* The following required packages can not be built:
* freetype, png
* Please check http://gnuwin32.sourceforge.net/packa
* ges/freetype.htm for instructions to install
* freetype
* Please check http://gnuwin32.sourceforge.net/packa
* ges/libpng.htm for instructions to install png
----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
Below is what the successful install looks like--
(testenv) PS C:\Users\jeff> pip install matplotlib
Collecting matplotlib
Downloading matplotlib-3.3.1-cp38-cp38-win_amd64.whl (8.5 MB)
|████████████████████████████████| 8.5 MB 2.2 MB/s
Collecting python-dateutil>=2.1
Using cached python_dateutil-2.8.1-py2.py3-none-any.whl (227 kB)
Collecting pillow>=6.2.0
Downloading Pillow-7.2.0-cp38-cp38-win_amd64.whl (2.1 MB)
|████████████████████████████████| 2.1 MB 1.7 MB/s
Collecting numpy>=1.15
Downloading numpy-1.19.1-cp38-cp38-win_amd64.whl (13.0 MB)
|████████████████████████████████| 13.0 MB 2.2 MB/s
Collecting pyparsing!=2.0.4,!=2.1.2,!=2.1.6,>=2.0.3
Using cached pyparsing-2.4.7-py2.py3-none-any.whl (67 kB)
Collecting certifi>=2020.06.20
Downloading certifi-2020.6.20-py2.py3-none-any.whl (156 kB)
|████████████████████████████████| 156 kB 3.3 MB/s
Collecting kiwisolver>=1.0.1
Downloading kiwisolver-1.2.0-cp38-none-win_amd64.whl (58 kB)
|████████████████████████████████| 58 kB 2.6 MB/s
Collecting cycler>=0.10
Using cached cycler-0.10.0-py2.py3-none-any.whl (6.5 kB)
Collecting six>=1.5
Using cached six-1.15.0-py2.py3-none-any.whl (10 kB)
Installing collected packages: six, python-dateutil, pillow, numpy, pyparsing, certifi, kiwisolver, cycler, matplotlib
Successfully installed certifi-2020.6.20 cycler-0.10.0 kiwisolver-1.2.0 matplotlib-3.3.1 numpy-1.19.1 pillow-7.2.0 pyparsing-2.4.7 python-dateutil-2.8.1 six-1.15.0
Guy Lorshbaugh
Python Development Techdegree Graduate 10,892 PointsExcellent! Good to know. I suppose I should have suspected as much, compatibility-wise. I wanted to be sure there wasn't some bigger issue I needed to be aware of. Thanks for your help!
Jeff Muday
Treehouse Moderator 28,722 PointsI am glad you are taking the time to install in your own virtual environment rather than going with something like Anaconda -- don't get me wrong, Anaconda is a fine product for Data Science.
However, as a Python programmer, you definitely want finer control over installed libraries/versions. This is especially true for people going into DevOps or the Internet of Things (IoT), type of Python development.