pip install matplotlib:"no pkg-config"

kjo*_*kjo 10 python macos pip matplotlib virtualenv

当我运行pip install matplotlib(在virtualenv中)时,第一行输出是:

Downloading/unpacking matplotlib
  Running setup.py egg_info for package matplotlib
    basedirlist is: ['/usr/local/', '/usr', '/usr/X11', '/opt/local']
    ============================================================================
    BUILDING MATPLOTLIB
                matplotlib: 1.2.0
                    python: 2.7.3 (default, Dec 14 2012, 13:31:05)  [GCC 4.2.1
                            (Apple Inc. build 5666) (dot 3)]
                  platform: darwin

    REQUIRED DEPENDENCIES
                     numpy: 1.6.2
                 freetype2: found, but unknown version (no pkg-config)

    OPTIONAL BACKEND DEPENDENCIES
                    libpng: found, but unknown version (no pkg-config)
                   Tkinter: Tkinter: 81008, Tk: 8.5, Tcl: 8.5
                      Gtk+: no
                            * Building for Gtk+ requires pygtk; you must be able
                            * to "import gtk" in your build/install environment
           Mac OS X native: yes
                        Qt: no
                       Qt4: no
                    PySide: no
                     Cairo: no
<snip>
Run Code Online (Sandbox Code Playgroud)

注意

  1. "没有pkg-config",和
  2. 缺少的Qt库.

首先,违背了上面的输出指出,什么pkg-config 实际上是安装在PATH:

% pkg-config --version
0.27.1
% which pkg-config
/usr/local/bin/pkg-config
Run Code Online (Sandbox Code Playgroud)

其次,qt是在同一个目录中可用的freetypelibpng被发现:

% ls -l /usr/local/opt/{freetype,libpng,qt} | cut -c43-
/usr/local/opt/freetype -> ../Cellar/freetype/2.4.10/
/usr/local/opt/libpng -> ../Cellar/libpng/1.5.13/
/usr/local/opt/qt -> ../Cellar/qt/4.8.4/
Run Code Online (Sandbox Code Playgroud)

我的问题有三个部分:

  1. 那到底pip install matplotlib是什么basedirlist(上面输出的第3行)?
  2. 我必须做些什么才能pip install matplotlib找到pkg-config
  3. 我必须做些什么才能pip install matplotlib找到qt

小智 11

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


zha*_*ing 11

在 Mac OS 上:which pkg-config用来检查安装。如果没有,请使用 brew 安装,它可以工作:

brew install pkg-config
Run Code Online (Sandbox Code Playgroud)


Aru*_*pal 7

只需安装freetype字体即可获得matplotlib.

sudo apt-get install freetype* 
Run Code Online (Sandbox Code Playgroud)

所有matplotlib文件都安装在/usr/local/lib/python2.7/site-packages/中.即使您想使用pip安装程序进行安装,也需要修复freetype字体问题,这可以按照上述说明完成.

  • 它对我不起作用.安装freetype*之后,我仍然收到错误消息,说明需要使用freetype.我不得不运行`sudo apt-get install pkg-config`. (2认同)

Leo*_*ara 2

我不能问你的具体问题,但我的 pip install matplotlib 看起来很像你前几天的。经过五个小时的头撞墙后,这个解决方案对我有用(来自practicalcomputing.org

我得到了这组命令来设置 simlinks:

sudo mkdir -p /usr/local/include
sudo ln -s /usr/X11/include/freetype2/freetype /usr/local/include/freetype
sudo ln -s /usr/X11/include/ft2build.h /usr/local/include/ft2build.h
sudo ln -s /usr/X11/include/png.h /usr/local/include/png.h
sudo ln -s /usr/X11/include/pngconf.h /usr/local/include/pngconf.h
sudo ln -s /usr/X11/include/pnglibconf.h /usr/local/include/pnglibconf.h
sudo mkdir -p /usr/local/lib
sudo ln -s /usr/X11/lib/libfreetype.dylib /usr/local/lib/libfreetype.dylib
sudo ln -s /usr/X11/lib/libpng.dylib /usr/local/lib/libpng.dylib
Run Code Online (Sandbox Code Playgroud)

它并不能完全解决您的所有问题,但它解决了我的 pkg-config 问题(以及其他问题)。也许类似的链接会对 QT 有所帮助。