zoukankan      html  css  js  c++  java
  • Pipenv使用出现编码错误UnicodeDecodeError: 'utf-8' codec can't decode ...

    Pipenv使用出现编码错误UnicodeDecodeError: 'utf-8' codec can't decode ...

    具体报错如下

    Traceback (most recent call last):
      File "c:python37-32lib
    unpy.py", line 193, in _run_module_as_main
        "__main__", mod_spec)
      File "c:python37-32lib
    unpy.py", line 85, in _run_code
        exec(code, run_globals)
      File "C:Python37-32Scriptspipenv.exe\__main__.py", line 5, in <module>
      File "c:python37-32libsite-packagespipenv\__init__.py", line 23, in <module>
        from .cli import cli
      File "c:python37-32libsite-packagespipenvcli\__init__.py", line 3, in <module>
        from .command import cli
      File "c:python37-32libsite-packagespipenvclicommand.py", line 7, in <module>
        import crayons
      File "c:python37-32libsite-packagespipenvpatchedcrayons.py", line 49, in <module>
        is_powershell = "powershell" in shellingham.detect_shell()[0]
      File "c:python37-32libsite-packagespipenvvendorshellingham\__init__.py", line 22, in detect_shell
        shell = get_shell(pid, max_depth=max_depth)
      File "c:python37-32libsite-packagespipenvvendorshellingham
    t.py", line 100, in get_shell
        processes = dict(_iter_process())
      File "c:python37-32libsite-packagespipenvvendorshellingham
    t.py", line 78, in _iter_process
        info = {'executable': str(pe.szExeFile.decode('utf-8'))}
    UnicodeDecodeError: 'utf-8' codec can't decode byte 0xce in position 0: invalid continuation byte
    

    原因:

    mark 进程名有中文, 这行代码 processes = dict(_iter_process())遍历了进程列表

    解决方法:

    法一.既然解决不了问题,那就解决制造问题的进程把,找到那个中文进程名的杀死。

    法二.重启电脑就解决了。

    还有的说法是:因为windows默认GBK编码,所以报错

    最正确的解决方式不清楚,我的解决方式是修改源码,亲测有效:将你报错位置的(报错位置在你的错误信息里)str(pe.szExeFile.decode('utf-8') 改为 str(pe.szExeFile.decode('gbk')

  • 相关阅读:
    解决:RuntimeError: invalid argument 0: Sizes of tensors must match except in dimension 0. Got 544 and 1935 in dimension 2 at ../aten/src/TH/generic/THTensor.cpp:711
    ubuntu16.04 notebook中(在anaconda的虚拟环境) 无法使用 anaconda的库
    多版本pip 指定下载
    Jmeter 使用-JDBC请求
    java基础函数
    Linux下安装bugfree
    linux下安装xampp
    Linux 常用命令
    Linux scp命令
    性能测试工具-Ngrinder使用之IDEA脚本开发环境配置
  • 原文地址:https://www.cnblogs.com/nymrli/p/11145352.html
Copyright © 2011-2022 走看看