49
43

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

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

Posted at

#環境

  • Windows 10
  • Python3.6

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

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

ファイル冒頭部分の

compat__init__.py
import os
import sys

compat__init__.py
import os
import sys
import locale

とする。

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')

と変更する。

保存する。

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

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'

#参考

49
43
4

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
49
43

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?