在没有root权限的情况下安装matplotlib及其依赖项

时间:2014-01-03 13:32:48

标签: python matplotlib module installation dependencies

我想在我没有root权限的帐户/myhome的服务器上使用matplotlib。

我下载了matplotlib源代码并尝试使用带有用户sheme的distutils安装它,比如python setup.py install --user,但它返回了以下消息:

============================================================================
Edit setup.cfg to change the build options

BUILDING MATPLOTLIB
        matplotlib: yes [1.3.1]
            python: yes [2.7.3 (default, Jan  2 2013, 13:56:14)  [GCC
                    4.7.2]]
          platform: yes [linux2]

REQUIRED DEPENDENCIES AND EXTENSIONS
             numpy: yes [version 1.6.2]
          dateutil: yes [using dateutil version 1.5]
           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.]
               png: yes [pkg-config information for 'libpng' could not
                    be found. Using unknown version.]

OPTIONAL SUBPACKAGES
       sample_data: yes [installing]
          toolkits: yes [installing]
             tests: yes [nose 0.11.1 or later is required to run the
                    matplotlib test suite]

OPTIONAL BACKEND EXTENSIONS
            macosx: no  [Mac OS-X only]
            qt4agg: yes [installing, Qt: 4.8.2, PyQt4: 4.9.3]
           gtk3agg: yes [installing, version 3.2.4]
         gtk3cairo: yes [installing, version 3.2.4]
            gtkagg: no  [The C/C++ header for gtk (gtk/gtk.h) could not
                    be found.  You may need to install the development
                    package.]
             tkagg: no  [TKAgg requires Tkinter.]
             wxagg: no  [requires wxPython]
               gtk: no  [The C/C++ header for gtk (gtk/gtk.h) could not
                    be found.  You may need to install the development
                    package.]
               agg: yes [installing]
             cairo: yes [installing, version 1.8.8]
         windowing: no  [Microsoft Windows only]

OPTIONAL LATEX DEPENDENCIES
            dvipng: yes [version 1.14]
       ghostscript: yes [version 9.05]
             latex: yes [version 3.1415926]
           pdftops: yes [version 0.18.4]

============================================================================
                    * The following required packages can not be built:
                    * freetype

似乎缺少“freetype”软件包,所以我下载了它的源代码,我发现它可以通过运行安装在特定的地方:

./configure --prefix=/myhome/somedir
make
make install

我的问题是:我在哪里安装freetype以便distutils可以检测到它?

我的第一个想法是将其安装在/myhome/.local中,因为这是distutils在使用--user选项时安装模块的地方。 不幸的是,在这样做时,我仍然得到与上面相同的信息。

我尝试使用virtualenv包创建一个更复杂的东西:

virtualenv /myhome/venv/

然后我在myhome/venv/中安装了freetype,最后我在这个虚拟环境中运行了distutils,但它再次给了我相同的消息。

感谢您的帮助,当然,我不会要求我的系统管理员为我安装matplotlib。

PS :肯定与我的问题无关,但也许值得注意:我使用./configure --prefix=/myhome/somedir --without-png安装了freetype软件包。如果没有--without-png选项,我会收到以下错误:

checking for libpng... configure: error: `libpng-config' not found;
either set the LIBPNG_CFLAGS and LIBPNG_LDFLAGS environment variables,
or pass `--without-png' to the `configure' script.

6 个答案:

答案 0 :(得分:8)

基于此处的一些建议和互联网上的其他说明,以下配方对我有用:

 wget http://download.savannah.gnu.org/releases/freetype/freetype-2.5.3.tar.gz
 tar xzf freetype-2.5.3.tar.gz
 cd freetype-2.5.3
 ./configure --prefix=/myhome/local --without-png
 make && make install
 export PKG_CONFIG_PATH=/myhome/local/lib/pkgconfig
 pip install matplotlib --upgrade

答案 1 :(得分:8)

你应该安装系统要求,它与python,pip,virtualenv无关。

要安装要求,请参阅此。 https://stackoverflow.com/a/20533455/2962018

简而言之,

的Ubuntu / Debian的

apt-get install libfreetype6-dev

红帽

yum -y install freetype-devel

OSX

brew install freetype

安装freetype后,尝试

pip install matplotlib

答案 2 :(得分:7)

从我所看到的情况来看,matplot设置最终将使用

调用提示符
pkg-config freetype2 --modversion 

尝试找到包。看来它在这次通话中失败了。

尝试查看该命令给出的错误并告诉我们。有关pkg-config的更多信息,请参阅http://people.freedesktop.org/~dbn/pkg-config-guide.html。在某些系统上可能没有安装pkg-config。

更新: 从我可以从matplotlib安装文件中获得的内容,它将在目录/ usr / local和/ usr中的子目录include,lib和lib64中搜索ft2build.h。

您可以在http://www.freetype.org/developer.html找到所需的freetype源文件(您需要.h文件,但获取所有这些文件并没有什么坏处。)

如果您无法访问任何这些目录,可以通过编辑setup.cfg中的matplotlib目录条目来为其搜索目录。

如果您无法编辑setup.cfg文件,还可以尝试直接编辑matplotlib目录中的setupext.py文件。在第95行,有一个函数get_base_dirs,你可以编辑这个函数来返回额外的目录供它搜索(它将在那些添加的目录中查找子目录include,lib和lib64)。

答案 3 :(得分:3)

现在可能已经很晚了,但我在使用matplotlib创建的virtualenv内安装virtualenvwrapper时遇到了同样的问题。

这些说明对我有用: http://newcoder.io/dataviz/part-0/

答案 4 :(得分:1)

专门针对mac: 我在安装matplotlib时遇到了类似的问题。按照这些说明完成操作:

  1. 使用brew安装python3。 (如果已经有,请忽略此步骤) 注意:To install brew.

    brew install freetype
    
  2. 安装freetype:

    brew install pkg-confi
    
  3. 现在使用pip3安装pkg-config:

    sudo pip3 install matplotlib
    
  4. 最后安装matplotlib:

     $(this).find('#editdiv').prop('contenteditable', true)
    

答案 5 :(得分:0)

我在安装matplotlib时遇到了同样的错误。安装pkg-config对我有用。对ubuntu尝试以下命令:

sudo apt-get install pkg-config
相关问题