首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >Matplotlib编译错误: TypeError:不可排序的类型: str() < int()

Matplotlib编译错误: TypeError:不可排序的类型: str() < int()
EN

Stack Overflow用户
提问于 2014-11-20 02:55:49
回答 1查看 5.8K关注 0票数 16

我正在尝试使用python setup.py build在Python3.4上添加matplotlib-1.4.2。根据文档,它在python3.4上受支持。我收到以下错误消息:

代码语言:javascript
复制
IMPORTANT WARNING:
    pkg-config is not installed.
    matplotlib may not be able to find some of its dependencies
============================================================================
Edit setup.cfg to change the build options

BUILDING MATPLOTLIB
            matplotlib: yes [1.4.2]
                python: yes [3.4.0 (default, Nov 17 2014, 15:12:48)  [GCC
                        4.1.2 20080704 (Red Hat 4.1.2-48)]]
              platform: yes [linux]

REQUIRED DEPENDENCIES AND EXTENSIONS
                 numpy: yes [version 1.9.1]
                   six: yes [using six version 1.8.0]
              dateutil: yes [using dateutil version 2.2]
                  pytz: yes [using pytz version 2014.9]
               tornado: yes [using tornado version 4.0.2]
             pyparsing: yes [pyparsing was not found. It is required for
                        mathtext support. pip/easy_install may attempt to
                        install it after matplotlib.]
                 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.]
Traceback (most recent call last):
  File "setup.py", line 155, in <module>
    result = package.check()
  File "/users/tools/downloads/matplotlib-1.4.2/setupext.py", line 962, in check
    min_version='2.3', version=version)
  File "/users/tools/downloads/matplotlib-1.4.2/setupext.py", line 446, in _check_for_pkg_config
    if (not is_min_version(version, min_version)):
  File "/users/tools/downloads/matplotlib-1.4.2/setupext.py", line 174, in is_min_version
    return found_version >= expected_version
  File "/users/tools/python-3.4.0/lib/python3.4/distutils/version.py", line 76, in __ge__
    c = self._cmp(other)
  File "/users/tools/python-3.4.0/lib/python3.4/distutils/version.py", line 342, in _cmp
    if self.version < other.version:
TypeError: unorderable types: str() < int()

请帮助我们解决这个问题。

EN

回答 1

Stack Overflow用户

发布于 2014-11-23 11:35:33

我遇到了类似的错误,并能够通过安装一个可选的依赖项来修复它。具体来说,在我的情况下,在distutil中有一个'bug‘,松散的版本号比较可能会在Python3中触发错误,因为在distutils/version.py:343中对字符串和整数类型进行隐式比较,这是从Matplotlib的setup.py调用的。如果您需要更多详细信息,请参阅Issue 14894

因为没有安装可选的依赖项,所以版本号检查返回一个字符串("Failed to identify version“)。当然,这不能与数字版本相比,后者抛出了与您看到的相同的异常。

代码语言:javascript
复制
sudo apt-get install libfreetype6-dev
pip install matplotlib

安装了libfreetype (一个可选的依赖项)后,distutil的LooseVersion看到了一个版本号,并且比较输入正确。此后Matplotlib安装得很好。

票数 52
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/27024731

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档