TypeError: unorderable types: str () <int ()

I used python 3.5 and all packages were the next versions

numpy-1.12.0b1+mkl-cp35-cp35m-win_amd64

scikit_learn-0.18.1-cp35-cp35m-win_amd64

scipy-0.18.1-cp35-cp35m-win_amd64

I use windows os.

when i use scikit_learn i got the following message:

Traceback (most recent call last):
  File "F:/liyulin/tf_idf2.py", line 7, in <module>
    from sklearn import feature_extraction  # sklearn是一个数据挖掘工具包
  File "C:\Users\lijia_xin\AppData\Local\Programs\Python\Python35\lib\site-packages\sklearn\__init__.py", line 57, in <module>
    from .base import clone
  File "C:\Users\lijia_xin\AppData\Local\Programs\Python\Python35\lib\site-packages\sklearn\base.py", line 12, in <module>
    from .utils.fixes import signature
  File "C:\Users\lijia_xin\AppData\Local\Programs\Python\Python35\lib\site-packages\sklearn\utils\__init__.py", line 11, in <module>
    from .validation import (as_float_array,
  File "C:\Users\lijia_xin\AppData\Local\Programs\Python\Python35\lib\site-packages\sklearn\utils\validation.py", line 18, in <module>
    from ..utils.fixes import signature
  File "C:\Users\lijia_xin\AppData\Local\Programs\Python\Python35\lib\site-packages\sklearn\utils\fixes.py", line 406, in <module>
    if np_version < (1, 12, 0):
TypeError: unorderable types: str() < int()
Process finished with exit code 1

This is my first question to ask questions.

Please help in solving it.

+4
source share
1 answer

Your version of numpy is numpy-1.12.0b1. Problem "b1" causes the problem. If you look at sklearn / utils / fixes.py , you will see the parse_version function there, which tries to do all the ints:

def _parse_version(version_string):
    version = []
    for x in version_string.split('.'):
        try:
            version.append(int(x))
        except ValueError:
            # x may be of the form dev-1ea1592
            version.append(x)
    return tuple(version)

np_version = _parse_version(np.__version__)

but in the case of "0b1" we will take the path ValueError. So this line

 if np_version < (1, 12, 0):

compares

>>> (1, 12, '0b1') < (1, 12, 0)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: unorderable types: str() < int()

. , numpy (, 1.11.2). numpy, fixes.py ,

if np_version < (1, 12, 0):

if np_version < (1, 12):

0 "0b1", False.

+13

Source: https://habr.com/ru/post/1661285/


All Articles