Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Matplotlib compilation error: TypeError: unorderable types: str() < int() [duplicate]

I am trying to add matplotlib-1.4.2 on python 3.4 using python setup.py build. According to documentation its supported on python 3.4. I am getting following error message:

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()

Kindly help in solving it.

like image 712
Raj Avatar asked Nov 19 '14 18:11

Raj


1 Answers

I ran into a similar error and was able to fix it by installing an optional dependency. Specifically, in my situation, there's a 'bug' in distutil where loose version number comparisons can trigger an error in Python 3 because of implicit comparisons of string and integer types in distutils/version.py:343, which is called from Matplotlib's setup.py. See Issue 14894 for more details if you want them.

Since the optional dependency wasn't installed the version number check was returning a string ("Failed to identify version.") and of course that can't be compared to a numeric version, which threw the same exception you saw.

sudo apt-get install libfreetype6-dev
pip install matplotlib

installed libfreetype (an optional dependency), distutil's LooseVersion saw a version number and the comparison was typed correctly. Matplotlib installed fine thereafter.

like image 143
Kwame Avatar answered Sep 30 '22 05:09

Kwame