机器学习100天相关报错处理方法

报错: ImportError: cannot import name ‘soft_unicode‘ from ‘markupsafe‘

解决方法:

在 terminal 中运行:

pip3 install –force-reinstall MarkupSafe==2.0.1

python3.8使用scikit-learn0.20.2时报错TypeError: an integer is required (got type bytes)

机器学习100天相关报错处理方法

【sklearn版本0.20】在报错信息中找到图示中文cloudpickle所在目录。打开对应文件后切换到148行左右

未修改的代码长这样:

<pre>def inner(value):
    lambda: cell  # make ``cell`` a closure so that we get a STORE_DEREF
    cell = value


co = inner.__code__

# NOTE: we are marking the cell variable as a free variable intentionally
# so that we simulate an inner function instead of the outer function. This
# is what gives us the ``nonlocal`` behavior in a Python 2 compatible way.
if not PY3:
    return types.CodeType(
        co.co_argcount,
        co.co_nlocals,
        co.co_stacksize,
        co.co_flags,
        co.co_code,
        co.co_consts,
        co.co_names,
        co.co_varnames,
        co.co_filename,
        co.co_name,
        co.co_firstlineno,
        co.co_lnotab,
        co.co_cellvars,  # this is the trickery
        (),
    )
else:
    return types.CodeType(
        co.co_argcount,
        co.co_kwonlyargcount,
        co.co_nlocals,
        co.co_stacksize,
        co.co_flags,
        co.co_code,
        co.co_consts,
        co.co_names,
        co.co_varnames,
        co.co_filename,
        co.co_name,
        co.co_firstlineno,
        co.co_lnotab,
        co.co_cellvars,  # this is the trickery
        (),
    )</pre>

在else:后面开始修改,改为:

args = [
co.co_argcount,
co.co_kwonlyargcount,
co.co_nlocals,
co.co_stacksize,
co.co_flags,
co.co_code,
co.co_consts,
co.co_names,
co.co_varnames,
co.co_filename,
co.co_name,
co.co_firstlineno,
co.co_lnotab,
co.co_cellvars, # this is the trickery
(),
]
if sys.version_info &gt;= (3, 8, 0):
args.insert(2, 0)
new_code = types.CodeType(*args)
return new_code

无觅相关文章插件,快速提升流量