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

时间:2013-12-12 01:35:07

标签: python ubuntu python-2.7 matplotlib pip

执行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吗?如何在Ubuntu 12.04中安装freetype,以便与matplotlib一起使用?

9 个答案:

答案 0 :(得分:217)

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

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

<强>的Ubuntu / Debian的:

apt-get install libfreetype6-dev

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

apt-cache search <string>

e.g:

apt-cache search freetype | grep dev

<强>红帽/ CentOS的/ Fedora的:

yum -y install freetype-devel

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

yum search <string>

e.g:

yum search freetype | grep devel

Mac OS X:通过Homebrew

brew install freetype

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

brew search <string>

e.g:

brew search freetype

答案 1 :(得分:140)

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

sudo apt-get install libfreetype6-dev libxft-dev

然后我可以使用

sudo easy_install matplotlib

答案 2 :(得分:29)

解决方法是执行sudo apt-get install pkg-config我找到in this github issue

答案 3 :(得分:6)

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

$ sudo apt-get install build-dep python-matplotlib
$ pip install matplotlib --upgrade

答案 4 :(得分:6)

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

对于python 2.x

sudo apt-get install python-matplotlib

对于python 3.x

sudo apt-get install python3-matplotlib

安装后,您可以尝试

(sudo) pip install matplotlib

答案 5 :(得分:4)

在Ubuntu上,我在安装SELECT 'about' AS a.about,title,null article ,null description FROM about a WHERE ( MATCH(a.about) AGAINST ('\"$search\"' IN BOOLEAN MODE) ) UNION SELECT 'articles' AS null, b.title,b.article,b.description from articles b WHERE ( MATCH(b.title,b.article,b.description) AGAINST ('\"$search\"' IN BOOLEAN MODE) AS relevence_1, MATCH(b.title,b.article,b.description) AGAINST ('\"$search\"' IN BOOLEAN MODE) AS relevence_2 ) ORDER BY (relevance_1 * 3) + (relevance_2 * 2) DESC 包之后就可以了。

blt-dev

答案 6 :(得分:1)

我正在使用Mint,这些答案都不适合我,我需要:

sudo apt-get install build-essential g++

答案 7 :(得分:1)

我在Windows上遇到了与Python 3.6相同的问题,但之后我切换到Python 3.5.2并且一切正常。

答案 8 :(得分:0)

这个命令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

所以我从source下载了已安装的freetype,归功于此guide

$ 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,一切正常。