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

use*_*933 13 python installation dependencies module matplotlib

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

我下载了matplotlib源代码并尝试使用distutils和用户sheme安装它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
Run Code Online (Sandbox Code Playgroud)

看起来包'freetype'丢失了,所以我下载了它的源代码,我发现它可以通过运行安装在特定的地方:

./configure --prefix=/myhome/somedir
make
make install
Run Code Online (Sandbox Code Playgroud)

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

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

我通过使用virtualenv包创建虚拟环境尝试了更复杂的事情:

virtualenv /myhome/venv/
Run Code Online (Sandbox Code Playgroud)

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

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

PS:肯定与我的问题无关,但也许值得注意:我通过使用安装freetype包./configure --prefix=/myhome/somedir --without-png.没有该--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.
Run Code Online (Sandbox Code Playgroud)

Mia*_*Kim 9

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

要安装这些要求,请参阅此处. /sf/answers/1437341881/

简而言之,

Ubuntu的/ Debian的

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

红帽

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

OSX

brew install freetype
Run Code Online (Sandbox Code Playgroud)

安装freetype后,试试吧

pip install matplotlib
Run Code Online (Sandbox Code Playgroud)


小智 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
Run Code Online (Sandbox Code Playgroud)


HSq*_*rel 7

从我所看到的,matplot安装程序最终会调用提示符

pkg-config freetype2 --modversion 
Run Code Online (Sandbox Code Playgroud)

试着找到包裹.好像它在这次通话中失败了.

尝试查看该命令给出的错误并告诉我们.有关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).