secretbase.log

.NET/C#/Pythonなど

Windows 7 / Python 2.7.6 にて ez_setup.py にて UnicodeDecodeError が出て困ったけど解決した件

追記 (2014/6/3)

Python ML にて報告がされていました。

Python 2.7.7 にて下記不具合として修正されていますので、2.7.7を使いましょう。



2系の最新版である Python 2.7.6 が出てました。新規に入れなおしてみよう思い、Python 2.7.6 をインストールし、ez_setup.py を実行し、まずはsetuptoolsをインストールしようとしたところ、なぜか UnicodeDecodeError に遭遇。

おかしい、他のWindowsマシンではうまくいくのに。

UnicodeDecodeError に遭遇

C:\Users\tkondou\Downloads>C:\Python27\python.exe ez_setup.py
Extracting in c:\users\tkondou\appdata\local\temp\tmpnnhcbl
Now working in c:\users\tkondou\appdata\local\temp\tmpnnhcbl\setuptools-2.0.1
Installing Setuptools
Traceback (most recent call last):
  File "setup.py", line 17, in <module>
    exec(init_file.read(), command_ns)
  File "<string>", line 8, in <module>
  File "c:\users\tkondou\appdata\local\temp\tmpnnhcbl\setuptools-2.0.1\setuptool
s\__init__.py", line 11, in <module>
    from setuptools.extension import Extension
  File "c:\users\tkondou\appdata\local\temp\tmpnnhcbl\setuptools-2.0.1\setuptool
s\extension.py", line 5, in <module>
    from setuptools.dist import _get_unpatched
  File "c:\users\tkondou\appdata\local\temp\tmpnnhcbl\setuptools-2.0.1\setuptool
s\dist.py", line 15, in <module>
    from setuptools.compat import numeric_types, basestring
  File "c:\users\tkondou\appdata\local\temp\tmpnnhcbl\setuptools-2.0.1\setuptool
s\compat.py", line 19, in <module>
    from SimpleHTTPServer import SimpleHTTPRequestHandler
  File "C:\Python27\lib\SimpleHTTPServer.py", line 27, in <module>
    class SimpleHTTPRequestHandler(BaseHTTPServer.BaseHTTPRequestHandler):
  File "C:\Python27\lib\SimpleHTTPServer.py", line 208, in SimpleHTTPRequestHand
ler
    mimetypes.init() # try to read system mime.types
  File "C:\Python27\lib\mimetypes.py", line 358, in init
    db.read_windows_registry()
  File "C:\Python27\lib\mimetypes.py", line 258, in read_windows_registry
    for subkeyname in enum_types(hkcr):
  File "C:\Python27\lib\mimetypes.py", line 249, in enum_types
    ctype = ctype.encode(default_encoding) # omit in 3.x!
UnicodeDecodeError: 'ascii' codec can't decode byte 0x83 in position 8: ordinal
not in range(128)
Something went wrong during the installation.
See the error message above.

mimetypes.py らしい

該当コードをみてみる。

C:\Python27\Lib\mimetypes.py あたり。

        with _winreg.OpenKey(_winreg.HKEY_CLASSES_ROOT, '') as hkcr:
            for subkeyname in enum_types(hkcr):

Windowsの場合、レジストリの HKEY_CLASSES_ROOT 以下のsubkeyをサーチしてごにょごにょしているようだ。


regeditでレジストリを開いてみる。

下記のような日本語名を含むエントリを発見。

f:id:cointoss1973:20131226121429p:plain

対処

安全のため、exportした上で、思い切って削除。

無事 ez_setup.py が通りました。めでたしめでたし。


う~ん、対処方法はこれで良かったんだろうか。