pip安装UnicodeDecodeError

Mil*_*ano 8 python windows pip

当我尝试使用pip在我的新笔记本(Win 7 64)上安装beautifulsoup4时,我收到此错误:

Cleaning up...
Exception:
Traceback (most recent call last):
  File "C:\Python27\lib\site-packages\pip\basecommand.py", line 122, in main
    status = self.run(options, args)
  File "C:\Python27\lib\site-packages\pip\commands\install.py", line 278, in run

    requirement_set.prepare_files(finder, force_root_egg_info=self.bundle, bundl
e=self.bundle)
  File "C:\Python27\lib\site-packages\pip\req.py", line 1234, in prepare_files
    req_to_install.assert_source_matches_version()
  File "C:\Python27\lib\site-packages\pip\req.py", line 464, in assert_source_ma
tches_version
    % (display_path(self.source_dir), version, self))
UnicodeDecodeError: 'ascii' codec can't decode byte 0x9e in position 58: ordinal
 not in range(128)

Traceback (most recent call last):
  File "C:\Python27\lib\runpy.py", line 162, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
  File "C:\Python27\lib\runpy.py", line 72, in _run_code
    exec code in run_globals
  File "C:\Python27\Scripts\pip.exe\__main__.py", line 9, in <module>
  File "C:\Python27\lib\site-packages\pip\__init__.py", line 185, in main
    return command.main(cmd_args)
  File "C:\Python27\lib\site-packages\pip\basecommand.py", line 161, in main
    text = '\n'.join(complete_log)
UnicodeDecodeError: 'ascii' codec can't decode byte 0x9e in position 73: ordinal
 not in range(128)
Run Code Online (Sandbox Code Playgroud)

我用:pip install beautifulsoup4命令

你知道问题出在哪里吗?

PS:笔记本电脑在获取之前用于演示,因此安装了多种语言的程序.

she*_*ain 20

或者简单地说,您可以在pip install之前在系统上运行以下命令,并且瞧:

export LC_ALL="en_US.UTF-8"
Run Code Online (Sandbox Code Playgroud)

  • 1)你能详细说明为什么你认为这有助于解决OP问题.也许它可以帮助别人.2)这看起来像一个bash命令.OP正在使用Windows,因此这对他没用. (5认同)

gwg*_*gwg 7

这是一个已知问题,pip未发布(截至2014年11月26日)修复.由于您使用的是Python 2.7,因此您现在可以手动修补pip.


obl*_*lex 5

这是因为您当前的工作目录包含非ascii字符.例如:

$ pwd
$ /home/abuser/????????
Run Code Online (Sandbox Code Playgroud)

这个问题仍然存在于pip 1.5.6中,这很糟糕.所以,你可以避免修补点,只需改变你的工作目录.

  • 不幸的是这对我不起作用。我将目录更改回“C:\”,但仍然出现错误。就我而言,我的用户名包含西里尔字符。 (2认同)