运行`pip install`的Ubuntu发出错误'无法构建以下必需的包:*freetype'

Ath*_*dom 143 python ubuntu pip matplotlib python-2.7

执行时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.]
Run Code Online (Sandbox Code Playgroud)

...

The following required packages can not be built:

                    * freetype
Run Code Online (Sandbox Code Playgroud)

还不应该pip install -r requirements.txt安装freetype?如何在Ubuntu 12.04中安装freetype以便它可以使用matplotlib

Jam*_*lls 218

pip将不会安装系统级的依赖性.这意味着pip不会安装RPM(基于Redhat的系统)或DEB(基于Debian的系统).

要安装系统依赖项,您需要使用以下方法之一,具体取决于您的系统.

Ubuntu的/ Debian的:

apt-get install libfreetype6-dev
Run Code Online (Sandbox Code Playgroud)

要在基于Ubuntu/Debian的系统上搜索包:

apt-cache search <string>
Run Code Online (Sandbox Code Playgroud)

例如:

apt-cache search freetype | grep dev
Run Code Online (Sandbox Code Playgroud)

红帽/ CentOS的/ Fedora的:

yum -y install freetype-devel
Run Code Online (Sandbox Code Playgroud)

要在Redhat/CentOS/Fedora系统上搜索软件包:

yum search <string>
Run Code Online (Sandbox Code Playgroud)

例如:

yum search freetype | grep devel
Run Code Online (Sandbox Code Playgroud)

Mac OS X的:(通过自制)

brew install freetype
Run Code Online (Sandbox Code Playgroud)

要在基于Mac OS X的系统上搜索包:

brew search <string>
Run Code Online (Sandbox Code Playgroud)

例如:

brew search freetype
Run Code Online (Sandbox Code Playgroud)

  • fwiw,`brew install freetype`在OSX上帮助了我 (9认同)
  • 我认为`-devel`约定适用于RPM而`-dev`约定适用于DEB.尝试`apt-cache search'^ libfreetype.* - dev $'`给出`libfreetype6-dev`. (2认同)

Sud*_*sak 141

我必须安装libxft-dev才能在ubuntu服务器14.04上启用matplotlib.

sudo apt-get install libfreetype6-dev libxft-dev
Run Code Online (Sandbox Code Playgroud)

然后我可以使用

sudo easy_install matplotlib
Run Code Online (Sandbox Code Playgroud)

  • 在Ubuntu 12.04 LTS上我还需要安装libxft-dev.感谢您提供额外信息 (10认同)
  • 显然,这里真正的依赖是`pkg-config`,`libxft-dev`也作为依赖安装.所以,正确的答案是运行`apt-get install libfreetype6-dev pkg-config` (10认同)
  • libxft-dev是为我做的!谢谢! (4认同)
  • 为什么不直接使用sudo apt-get install python-matplotlib,如下所示:http://matplotlib.org/users/installing.html (3认同)
  • 我已经安装了libfreetype6-dev.这对我在ubuntu 14.10上有所帮助,谢谢! (2认同)

not*_*ing 28

sudo apt-get install pkg-config在github问题中找到一个解决方法.

  • 安装``pkg-config``对我来说也是一个缺失不直观的步骤,这是在一个docker容器中以``ubuntu:14.04``作为基本映像安装``matplotlib``. (3认同)

Pau*_*est 6

现有的答案都不适合我在Ubuntu上升级matplotlib.这最终对我有用:

$ sudo apt-get install build-dep python-matplotlib
$ pip install matplotlib --upgrade
Run Code Online (Sandbox Code Playgroud)


Mia*_*Kim 6

此命令将下载所有依赖项.

对于python 2.x

sudo apt-get install python-matplotlib
Run Code Online (Sandbox Code Playgroud)

对于python 3.x

sudo apt-get install python3-matplotlib
Run Code Online (Sandbox Code Playgroud)

安装后,您可以尝试

(sudo) pip install matplotlib
Run Code Online (Sandbox Code Playgroud)