点击Python Console报错TypeError: an integer is required (got type bytes)

点击Python Console后直接报错
点击Python Console报错TypeError: an integer is required (got type bytes)_第1张图片
解决办法:
仔细查阅会发现有一个_compat.py文件报错。找到这个并修改
点击Python Console报错TypeError: an integer is required (got type bytes)_第2张图片
注释掉101行到116行的代码,即

    # if PY3:
    #     new_code = types.CodeType(len(varnames),
    #                               0,
    #                               len(varnames),
    #                               code.co_stacksize,
    #                               code.co_flags,
    #                               code.co_code,
    #                               code.co_consts,
    #                               code.co_names,
    #                               varnames,
    #                               code.co_filename,
    #                               "__init__",
    #                               code.co_firstlineno,
    #                               code.co_lnotab,
    #                               code.co_freevars,
    #                               code.co_cellvars)

注释掉之后替换成以下的代码片段:

args = [len(varnames),
          0,
          len(varnames),
          code.co_stacksize,
          code.co_flags,
          code.co_code,
          code.co_consts,
          code.co_names,
          varnames,
          code.co_filename,
          "__init__",
          code.co_firstlineno,
          code.co_lnotab,
          code.co_freevars,
          code.co_cellvars]
    if sys.version_info >= (3,8,0):
        args.insert(2,0)
        new_code = types.CodeType(*args)

点击Python Console报错TypeError: an integer is required (got type bytes)_第3张图片
修改完后,再次点击Python Console
点击Python Console报错TypeError: an integer is required (got type bytes)_第4张图片
Success

你可能感兴趣的:(问题解决,python,开发语言)