Skip to main content
 首页 » 编程设计

python之在 Windows 64 位 python 3.5 上安装 matplotlib

2025年05月04日13落叶

因为还没有 official release对于 python 3.5 的 matplotlib,我尝试使用 pip。

pip install matplotlib 

它说我缺少一些必需的依赖项和扩展

REQUIRED DEPENDENCIES AND EXTENSIONS 
                 numpy: yes [version 1.10.0.post2] 
                   six: yes [using six version 1.9.0] 
              dateutil: yes [using dateutil version 2.4.2] 
                  pytz: yes [using pytz version 2015.6] 
               tornado: yes [using tornado version 4.2.1] 
             pyparsing: yes [using pyparsing version 2.0.3] 
                 pycxx: yes [Official versions of PyCXX are not compatible 
                        with matplotlib on Python 3.x, since they lack 
                        support for the buffer object.  Using local copy] 
                libagg: yes [pkg-config information for 'libagg' could not 
                        be found. Using local copy.] 
              freetype: no  [The C/C++ header for freetype (ft2build.h) 
                        could not be found.  You may need to install the 
                        development package.] 
                   png: no  [The C/C++ header for png (png.h) could not be 
                        found.  You may need to install the development 
                        package.] 
                 qhull: yes [pkg-config information for 'qhull' could not be 
                        found. Using local copy.] 
[...] 
Command "python setup.py egg_info" failed with error code 1 in C:\Users\me\AppData\Local\Temp\pip-build-bjiqixce\matplotlib 

但是我的系统上安装了 freetype 和 png。

C:\Users\me>where ft2build.h 
C:\Users\me\libs\GnuWin32\include\ft2build.h 
C:\Users\me>where png.h 
C:\Users\me\libs\GnuWin32\include\png.h 

所有这些都是使用普通用户权限安装的。我在这里做错了什么?

编辑:yay python 3.5 版本现在存在。

请您参考如下方法:

诺兹鼓,

在为 python 3.5 安装 Matplotlib 时,我遇到了与您相同的问题。对我有用的是首先下载 CMake 的二进制发行版之一。然后用 ISO 安装 VB2010对于 VS2010。在我完成 CMake 和 VB2010 的下载和安装后,我再次运行

pip install matplotlib 

此外,如果以前的解决方案不起作用,虽然以下对我不起作用,但有一组由 jbmohler 编译的脚本,用于在 windows 上构建 matplotlib:

this is a set of scripts to build matplotlib from source on the MS Windows platform. It builds matplotlib requiring only Visual Studio and CMake as pre-requisites; other library dependencies are embedded in this repository. Any complicated or other dependencies are considered bugs in this build script.

The Python shipped from http://www.python.org is compiled with Visual Studio 2008 for versions before 3.3 and Visual Studio 2010 for 3.3 and later. Python extensions are recommended to be compiled with the same compiler. These scripts and the matplotlib setup.py look for the correct version via distutils. The .NET Framework 4.0 is required for MSBuild, but you likely already have it.

In addition to Visual Studio CMake is required for building libpng. For building documentation, you will need to install numpydoc and miktex. The required freetype, zlib, libpng, tcl, & tk source code is bundled with this repository since there is no canonical Windows package manager.

To build & install matplotlib in your Python, do:

git clone https://github.com/matplotlib/matplotlib  
git clone https://github.com/jbmohler/matplotlib-winbuild             
python matplotlib-winbuild\buildall.py 

The build script will auto-detect Python version & 32/64 bit automatically.

The origin of these scripts is the comment by cgohlke in https://github.com/matplotlib/matplotlib/issues/1717