pip install UnicodeDecodeError

2020-01-29 10:30发布

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

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

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.

4条回答
Viruses.
2楼-- · 2020-01-29 11:01

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

$ 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.

查看更多
ゆ 、 Hurt°
3楼-- · 2020-01-29 11:04

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

查看更多
狗以群分
4楼-- · 2020-01-29 11:11

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

查看更多
一纸荒年 Trace。
5楼-- · 2020-01-29 11:17

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

export LC_ALL="en_US.UTF-8"
查看更多
登录 后发表回答