Help us understand the problem. What is going on with this article?

Win + Python3.6で「pip install」を実行したときに「UnicodeDecodeError: 'utf-8' codec can't decode byte 0x83」と表示される。

More than 1 year has passed since last update.

環境

  • Windows 10
  • Python3.6

事象

「pip install」を実行したときに、「UnicodeDecodeError: 'utf-8' codec can't decode byte 0x83」というエラーメッセージが表示される。

対応策

1.
pip\compat\__init__.py (環境によって場所は違う。下記エラーメッセージ例の1つめのハイライト箇所が指す__init__.pyを編集すること)をテキストエディタで開く。

2.
ファイル冒頭部分の

compat\__init__.py
import os
import sys

compat\__init__.py
import os
import sys
import locale

とする。

3.

compat\__init__.py
if sys.version_info >= (3,):
    def console_to_str(s):
        try:
            return s.decode(sys.__stdout__.encoding)
        except UnicodeDecodeError:
            return s.decode('utf_8')

compat\__init__.py
if sys.version_info >= (3,):
    def console_to_str(s):
        # try:
        #     return s.decode(sys.__stdout__.encoding)
        # except UnicodeDecodeError:
        #     return s.decode('utf_8')
        return s.decode(locale.getpreferredencoding() or "utf-8", 'replace')

と変更する。

4.
保存する。

該当のエラーメッセージ例

pipinstall
(C:\Users\name_\AppData\Local\conda\conda\envs\tensorflow) C:\Users\name_>pip install cupy
Collecting cupy
  Using cached cupy-2.0.0.tar.gz
Exception:
Traceback (most recent call last):
  File "C:\Users\name_\AppData\Local\conda\conda\envs\tensorflow\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 0x83 in position 95: invalid start byte

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\name_\AppData\Local\conda\conda\envs\tensorflow\lib\site-packages\pip\commands\install.py", line 335, in run
    wb.build(autobuilding=True)
  File "C:\Users\name_\AppData\Local\conda\conda\envs\tensorflow\lib\site-packages\pip\wheel.py", line 749, in build
    self.requirement_set.prepare_files(self.finder)
  File "C:\Users\name_\AppData\Local\conda\conda\envs\tensorflow\lib\site-packages\pip\req\req_set.py", line 380, in prepare_files
    ignore_dependencies=self.ignore_dependencies))
  File "C:\Users\name_\AppData\Local\conda\conda\envs\tensorflow\lib\site-packages\pip\req\req_set.py", line 634, in _prepare_file
    abstract_dist.prep_for_dist()
  File "C:\Users\name_\AppData\Local\conda\conda\envs\tensorflow\lib\site-packages\pip\req\req_set.py", line 129, in prep_for_dist
    self.req_to_install.run_egg_info()
  File "C:\Users\name_\AppData\Local\conda\conda\envs\tensorflow\lib\site-packages\pip\req\req_install.py", line 439, in run_egg_info
    command_desc='python setup.py egg_info')
  File "C:\Users\name_\AppData\Local\conda\conda\envs\tensorflow\lib\site-packages\pip\utils\__init__.py", line 676, in call_subprocess
    line = console_to_str(proc.stdout.readline())
  File "C:\Users\name_\AppData\Local\conda\conda\envs\tensorflow\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 0x83 in position 95: invalid start byte

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\name_\AppData\Local\conda\conda\envs\tensorflow\lib\site-packages\pip\basecommand.py", line 215, in main
    status = self.run(options, args)
  File "C:\Users\name_\AppData\Local\conda\conda\envs\tensorflow\lib\site-packages\pip\commands\install.py", line 385, in run
    requirement_set.cleanup_files()
  File "C:\Users\name_\AppData\Local\conda\conda\envs\tensorflow\lib\site-packages\pip\utils\build.py", line 38, in __exit__
    self.cleanup()
  File "C:\Users\name_\AppData\Local\conda\conda\envs\tensorflow\lib\site-packages\pip\utils\build.py", line 42, in cleanup
    rmtree(self.name)
  File "C:\Users\name_\AppData\Local\conda\conda\envs\tensorflow\lib\site-packages\pip\_vendor\retrying.py", line 49, in wrapped_f
    return Retrying(*dargs, **dkw).call(f, *args, **kw)
  File "C:\Users\name_\AppData\Local\conda\conda\envs\tensorflow\lib\site-packages\pip\_vendor\retrying.py", line 212, in call
    raise attempt.get()
  File "C:\Users\name_\AppData\Local\conda\conda\envs\tensorflow\lib\site-packages\pip\_vendor\retrying.py", line 247, in get
    six.reraise(self.value[0], self.value[1], self.value[2])
  File "C:\Users\name_\AppData\Local\conda\conda\envs\tensorflow\lib\site-packages\six.py", line 686, in reraise
    raise value
  File "C:\Users\name_\AppData\Local\conda\conda\envs\tensorflow\lib\site-packages\pip\_vendor\retrying.py", line 200, in call
    attempt = Attempt(fn(*args, **kwargs), attempt_number, False)
  File "C:\Users\name_\AppData\Local\conda\conda\envs\tensorflow\lib\site-packages\pip\utils\__init__.py", line 102, in rmtree
    onerror=rmtree_errorhandler)
  File "C:\Users\name_\AppData\Local\conda\conda\envs\tensorflow\lib\shutil.py", line 494, in rmtree
    return _rmtree_unsafe(path, onerror)
  File "C:\Users\name_\AppData\Local\conda\conda\envs\tensorflow\lib\shutil.py", line 384, in _rmtree_unsafe
    _rmtree_unsafe(fullname, onerror)
  File "C:\Users\name_\AppData\Local\conda\conda\envs\tensorflow\lib\shutil.py", line 393, in _rmtree_unsafe
    onerror(os.rmdir, path, sys.exc_info())
  File "C:\Users\name_\AppData\Local\conda\conda\envs\tensorflow\lib\site-packages\pip\utils\__init__.py", line 114, in rmtree_errorhandler
    func(path)
PermissionError: [WinError 32] プロセスはファイルにアクセスできません。別のプロセスが使用中です。: 'C:\\Users\\name_\\AppData\\Local\\Temp\\pip-build-gtomq_do\\cupy'

参考

Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした