Python pip 安装 UnicodeDecodeError

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/25036897/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-18 19:37:31  来源:igfitidea点击:

pip install UnicodeDecodeError

pythonwindowspip

提问by Milano

When I'm trying to install beautifulsoup4 on my new notebook (Win 7 64) using pip, I get this error:

当我尝试使用 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)

I use: pip install beautifulsoup4command

我使用:pip install beautifulsoup4命令

Do you have an idea where could be the problem?

您知道问题出在哪里吗?

PS: The notebook was used for presentations before get it, so there are programs in multiple languages installed.

PS:笔记本在拿到之前是用来做演示的,所以安装了多国语言的程序。

采纳答案by oblalex

This is because your current working directory contains non-ascii characters. E.g.:

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

$ pwd
$ /home/abuser/Загрузки

This issue is still present in pip 1.5.6 and this is awful. So, you can avoid patching pip and just change your working dir.

这个问题仍然存在于 pip 1.5.6 中,这很糟糕。因此,您可以避免修补 pip 而只需更改您的工作目录。

回答by gwg

This is a known issue with pipwith an unreleased (as of 26/11/2014) fix. Since you are using Python 2.7, you can manually patch pipfor now.

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

回答by sherifzain

Or simply, you can run the following command on your system right before pip install, and voila:

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

export LC_ALL="en_US.UTF-8"

回答by Libor Jelinek

In my case it was caused because where were non US-ASCII letters in requirements.txt

在我的情况下,这是因为非 US-ASCII 字母在 requirements.txt