关于python:pip install&UnicodeDecodeError:’utf-8’编解码器无法解码位置9的字节0xe0:无效的连续字节

pip install & UnicodeDecodeError: 'utf-8' codec can't decode byte 0xe0 in position 9: invalid continuation byte

尝试安装:

1
pip install python-binance

结果:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
Exception:
Traceback (most recent call last):
  File"c:\usersнна\appdata\local\programs\python\python36\lib\site-packages\pip\compat\__init__.py", line 73, in console_to_str
    return s.decode(sys.__stdout__.encoding)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xe0 in position 9: invalid continuation byte

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File"c:\usersнна\appdata\local\programs\python\python36\lib\site-packages\pip\basecommand.py", line 215, in main
    status = self.run(options, args)
  File"c:\usersнна\appdata\local\programs\python\python36\lib\site-packages\pip\commands\install.py", line 324, in run
    requirement_set.prepare_files(finder)
  File"c:\usersнна\appdata\local\programs\python\python36\lib\site-packages\pip
eq
eq_set.py", line 380, in prepare_files
    ignore_dependencies=self.ignore_dependencies))
  File"c:\usersнна\appdata\local\programs\python\python36\lib\site-packages\pip
eq
eq_set.py", line 634, in _prepare_file
    abstract_dist.prep_for_dist()
  File"c:\usersнна\appdata\local\programs\python\python36\lib\site-packages\pip
eq
eq_set.py", line 129, in prep_for_dist
    self.req_to_install.run_egg_info()
  File"c:\usersнна\appdata\local\programs\python\python36\lib\site-packages\pip
eq
eq_install.py", line 439, in run_egg_info
    command_desc='
python setup.py egg_info')
  File"c:\usersнна\appdata\local\programs\python\python36\lib\site-packages\pip\utils\__init__.py", line 676, in call_subprocess
    line = console_to_str(proc.stdout.readline())
  File"c:\usersнна\appdata\local\programs\python\python36\lib\site-packages\pip\compat\__init__.py", line 75, in console_to_str
    return s.decode('
utf_8')
UnicodeDecodeError: '
utf-8' codec can't decode byte 0xe0 in position 9: invalid continuation byte

怎么解决?


好的...

  • 由于错误在我的文件中:

    c:\users\анна\appdata\local\programs\python\python36\lib\site-packages\pip\compat__init__.py

  • 问题文件夹是'анна',这是cp1251

  • 第一个解决方案是找到如何重命名用户的文件夹。 (重新安装操作系统除外)。 到拉丁字母的文件夹

  • 文件compat__init__.py中的第二个路径 - 替换

    return s.decode(sys.__stdout__.encoding)

  • return s.decode('cp1251')

  • 当然,你需要知道你有什么编码。 在我看来cp1251,在你身上它可以是拉丁语(例如)。 在文件中替换后 - 一切都安装成功!

    谢谢2个cowbert


    我建议使用快速修复这种情况。 修复是通过将输出从标准方向(终端)重定向到文件来完成的,如下所示:

    1
    pip install python-binance > temp_output_file

    如果你需要打开它......