我无法在OS X(10.12.6)的虚拟环境中使用matplotlib
安装pip
。我正在使用Python的内置系统版本(/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7
),这是Python 2的唯一安装版本。
我使用virtualenv
(版本15.1.0)来创建虚拟环境。 matplotlib
安装控制台输出表明它无法构建freetype
包,但我已经使用brew
(已将其安装在/usr/local/Cellar/freetype
中)安装了此包。这是安装控制台输出:
(venv) $ pip install matplotlib
You are using pip version 7.0.3, however version 9.0.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
Collecting matplotlib
Using cached matplotlib-2.0.2.tar.gz
Complete output from command python setup.py egg_info:
IMPORTANT WARNING:
pkg-config is not installed.
matplotlib may not be able to find some of its dependencies
============================================================================
Edit setup.cfg to change the build options
BUILDING MATPLOTLIB
matplotlib: yes [2.0.2]
python: yes [2.7.10 (default, Feb 7 2017, 00:08:15) [GCC
4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.34)]]
platform: yes [darwin]
REQUIRED DEPENDENCIES AND EXTENSIONS
numpy: yes [not found. pip may install it below.]
six: yes [using six version 1.10.0]
dateutil: yes [using dateutil version 2.6.1]
functools32: yes [functools32 was not found. It is required
forPython versions prior to 3.2]
subprocess32: yes [subprocess32 was not found. It used for Python
versions prior to 3.2 to improves functionality on
Linux and OSX]
pytz: yes [using pytz version 2017.2]
cycler: yes [cycler was not found. pip will 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.]
libagg: yes [pkg-config information for 'libagg' could not
be found. Using local copy.]
freetype: no [The C/C++ header for freetype2 (ft2build.h)
could not be found. You may need to install the
development package.]
png: yes [version 1.6.31]
qhull: yes [pkg-config information for 'qhull' 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: yes [installing, darwin]
qt5agg: no [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: no [Microsoft Windows only]
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
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /private/var/folders/vx/3ts13s190k50b2gzt_6zyp0m0000gn/T/pip-build-HCJwzO/matplotlib
答案 0 :(得分:0)
好的,所以我设法通过使用pkg-config
安装和链接brew
包,然后在虚拟环境中运行pip install matplotlib
来解决此问题。