问题:运行`pip install`的Ubuntu给出错误’无法构建以下必需的软件包:* freetype’
执行时pip install -r requirements.txt,在安装阶段出现以下错误matplotlib:
REQUIRED DEPENDENCIES AND EXTENSIONS
                 numpy: yes [not found. pip may install it below.]
              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: no  [pkg-config information for 'freetype2' could
                        not be found.]…
The following required packages can not be built:
                    * freetype还不应该pip install -r requirements.txt安装freetype吗?freetype应该如何在Ubuntu 12.04中安装以便与它一起使用matplotlib?
回答 0
否。pip不会安装系统级别的依赖项。这意味着pip将不会安装RPM(基于Redhat的系统)或DEB(基于Debian的系统)。
要安装系统依赖项,您将需要根据系统使用以下方法之一。
Ubuntu / Debian:
apt-get install libfreetype6-dev要在基于Ubuntu / Debian的系统上搜索软件包:
apt-cache search <string>例如:
apt-cache search freetype | grep devRedhat / CentOS / Fedora:
yum -y install freetype-devel要在基于Redhat / CentOS / Fedora的系统上搜索软件包:
yum search <string>例如:
yum search freetype | grep develMac OS X的:(通过自制)
brew install freetype在基于Mac OS X的系统上搜索软件包:
brew search <string>例如:
brew search freetype回答 1
我必须安装libxft-dev才能在ubuntu服务器14.04上启用matplotlib。
sudo apt-get install libfreetype6-dev libxft-dev然后我可以使用
sudo easy_install matplotlib回答 2
sudo apt-get install pkg-config我在此github问题中发现了一种解决方法。
回答 3
现有的答案都无法在Ubuntu上升级matplotlib。这最终对我有用:
$ sudo apt-get install build-dep python-matplotlib
$ pip install matplotlib --upgrade回答 4
此命令将下载所有依赖项。
对于python 2.x
sudo apt-get install python-matplotlib对于python 3.x
sudo apt-get install python3-matplotlib安装后,您可以尝试
(sudo) pip install matplotlib回答 5
在Ubuntu上,安装blt-dev软件包后它可以工作。
$sudo apt-get install blt-dev
$pip install matplotlib回答 6
我正在使用Mint,但以下答案均不适合我,我需要:
sudo apt-get install build-essential g++回答 7
我在Windows上使用Python 3.6时遇到了同样的问题,但是后来我切换到Python 3.5.2,一切正常。
回答 8
这个命令sudo apt-get install libfreetype6-dev对我来说在Ubuntu 16.04上失败了,
The following packages have unmet dependencies:
     libfreetype6-dev : Depends: libfreetype6 (= 2.6.1-0.1ubuntu2) but 
     2.6.1-0.1ubuntu2.3 is to be installed
因此,我从源代码下载了已安装的freetype ,请参考本指南
$ tar -xvjf freetype-x.y.tar.bz2  # extract the downloaded version file
$ cd freetype-x.y/ 
$ ./configure
$ make
$ sudo make install 切换到virtualenv并且pip install matplotlib一切正常。

