简体   繁体   English

pip 安装 UnicodeDecodeError

[英]pip install UnicodeDecodeError

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 beautifulsoup4 command我使用: 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:笔记本拿到手之前是做演示用的,所以里面安装了多国语言的程序。

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

export LC_ALL="en_US.UTF-8"

This is a known issue with pip with an unreleased (as of 26/11/2014) fix. 这是一个已知的问题, pip与未发布(截至2014年11月26日)修复。 Since you are using Python 2.7, you can manually patch pip for now. 由于您使用的是Python 2.7,因此您现在可以手动修补pip

This is because your current working directory contains non-ascii characters. 这是因为您当前的工作目录包含非ascii字符。 Eg: 例如:

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

This issue is still present in pip 1.5.6 and this is awful. 这个问题仍然存在于pip 1.5.6中,这很糟糕。 So, you can avoid patching pip and just change your working dir. 所以,你可以避免修补点,只需改变你的工作目录。

在我的情况下,它是由于requirements.txt中的非US-ASCII字母而引起的

In my case it was because pip was facing encoding issues when reading setup.cfg file of the repository.就我而言,这是因为 pip 在读取存储库的 setup.cfg 文件时遇到编码问题。 Initially when I used PyCharm venvpy creator with default terminal set to gitbash, I was constantly getting this error.最初,当我使用默认终端设置为 gitbash 的 PyCharm venvpy creator 时,我不断收到此错误。 Then I manually created my virtual environment with venv in powershell and I didn't get this error, although I got following warning WARNING: Ignore distutils configs in setup.cfg due to encoding errors.然后我在 powershell 中使用 venv 手动创建了我的虚拟环境,但我没有收到此错误,尽管我收到以下警告 WARNING: Ignore distutils configs in setup.cfg due to encoding errors。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM