2
  • I'm using Python 3.5.0 on Windows 7 64-bit
  • My user name and full computer name both contains Slavic character: ł
  • Therefore this character is in some file paths and environmental variables
  • EDIT: Normally my active code page is 852

I'm getting this error on my CMD while trying to install some packages (not every):
UnicodeDecodeError: 'charmap' codec can't decode byte 0x88 in position "some_number": character maps to <undefined>

Example for package lib2d:

C:\Python35\Scripts\lib2d-0.0.2> c:\python35\python.exe setup.py install
running install
running build
running build_py
running build_ext
building '_lib2d' extension
Traceback (most recent call last):
  File "setup.py", line 51, in <module>
    scripts=['scripts/premultiplyalpha.py']
  File "c:\python35\lib\distutils\core.py", line 148, in setup
    dist.run_commands()
  File "c:\python35\lib\distutils\dist.py", line 955, in run_commands
    self.run_command(cmd)
  File "c:\python35\lib\distutils\dist.py", line 974, in run_command
    cmd_obj.run()
  File "c:\python35\lib\distutils\command\install.py", line 539, in run
    self.run_command('build')
  File "c:\python35\lib\distutils\cmd.py", line 313, in run_command
    self.distribution.run_command(command)
  File "c:\python35\lib\distutils\dist.py", line 974, in run_command
    cmd_obj.run()
  File "c:\python35\lib\distutils\command\build.py", line 135, in run
    self.run_command(cmd_name)
  File "c:\python35\lib\distutils\cmd.py", line 313, in run_command
    self.distribution.run_command(command)
  File "c:\python35\lib\distutils\dist.py", line 974, in run_command
    cmd_obj.run()
  File "c:\python35\lib\distutils\command\build_ext.py", line 338, in run
    self.build_extensions()
  File "c:\python35\lib\distutils\command\build_ext.py", line 447, in    build_extensions
    self._build_extensions_serial()
  File "c:\python35\lib\distutils\command\build_ext.py", line 472, in _build_extensions_serial
    self.build_extension(ext)
  File "c:\python35\lib\distutils\command\build_ext.py", line 532, in build_extension
    depends=ext.depends)
  File "c:\python35\lib\distutils\_msvccompiler.py", line 315, in compile
    self.initialize()
  File "c:\python35\lib\distutils\_msvccompiler.py", line 208, in initialize
    vc_env = _get_vc_env(plat_spec)
  File "c:\python35\lib\distutils\_msvccompiler.py", line 90, in _get_vc_env
    universal_newlines=True,
  File "c:\python35\lib\subprocess.py", line 629, in check_output
    **kwargs).stdout
  File "c:\python35\lib\subprocess.py", line 698, in run
    stdout, stderr = process.communicate(input, timeout=timeout)
  File "c:\python35\lib\subprocess.py", line 1055, in communicate
    stdout = self.stdout.read()
  File "c:\python35\lib\encodings\cp1250.py", line 23, in decode
    return codecs.charmap_decode(input,self.errors,decoding_table)[0]
UnicodeDecodeError: 'charmap' codec can't decode byte 0x88 in position 162: character maps to <undefined>  

Similar error occurs with pip install lib2d and for building wheels
pip and wheels are up-to-date

I've done some research and it shows:
1. byte 0x88 in code page 852 is: ł - LATIN SMALL LETTER L WITH STROKE
2. it was very unwise to use "nonstandard character" in user and computer name (I was young and inexperienced)
3. changing full computer name is bad idea because license issues and then other programs now working might stop working due to the confusing change
4. Python installer tries to interpret that character in code page 1250 where it's undefined
5. Python shouldn't be unfamiliar with cp852, but it's wrongly assuming CMD has cp1250
6. ł - LATIN SMALL LETTER L WITH STROKE in cp1250 is byte 0xB3
7. it seems to be the only reason why building fails for me
8. other "nonstandard character users" may encounter the same problem because bytes: 0x81; 0x83; 0x90; 0x98; are unassigned in cp1250 but are assigned in cp852; cp775; cp 437; and other

So, is there a way to solve this installing/building obstacle and how to do it?
Maybe I should change and/or add something to Pythons file codecs.py? - trying to guess

I've tried chcp 1250 in CMD but it produces another, this time different error (see example below).

Example for package lib2d:

C:\Python35\Scripts\lib2d-0.0.2> c:\python35\python.exe setup.py install
running install
running build
running build_py
running build_ext
building '_lib2d' extension
creating build\temp.win-amd64-3.5
creating build\temp.win-amd64-3.5\Release
creating build\temp.win-amd64-3.5\Release\src
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\amd64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -Iinclude -Ic:\python35\include -Ic:\python35\include "-IC:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\INCLUDE" "-IC:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\ATLMFC\INCLUDE" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\NETFXSDK\4.6.1\include\um" "-IC:\Program Files (x86)\Windows Kits\8.1\include\\shared" "-IC:\Program Files (x86)\Windows Kits\8.1\include\\um" "-IC:\Program Files (x86)\Windows Kits\8.1\include\\winrt" /Tcsrc/anim.c /Fobuild\temp.win-amd64-3.5\Release\src/anim.obj -std=c99
cl : Command line warning D9002 : ignoring unknown option '-std=c99'
anim.c
src/anim.c(1): fatal error C1083: Cannot open include file: 'lib2d.h': No such file or directory
error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\BIN\\amd64\\cl.exe' failed with exit status 2

Is solving this other error a simpler road, if it is then how to do it?

Aven
  • 21
  • 5
  • What is your codepage normally (what does `chcp` return?). Does `chcp 852` do anything? What about `chcp 65001`? If you do not get a good answer here on SO, try python-list, mirrored as newsgroup gmane.comp.python.general at news.gmane.org. – Terry Jan Reedy Dec 26 '15 at 19:48
  • It actually looks like `chcp 1250` already solved the problem with ł. The build problem is something else entirely, probably idiosyncratic to lib2d. Is it advertised as 3.5 compatible? The 'unknown option' suggests that the build file has not been adjucted for the new VS release. Is VS 14.0 the same as VS 2015, used to compile 3.5? – Terry Jan Reedy Dec 26 '15 at 19:55
  • @TerryJanReedy **Thank you**. Your questions and suggestions showed me what was almost in front of my eyes. I used lib2d as an example because error log was shorter then for numpy which I **also** couldn't install. I normally have **CP852**, so yes, you were right when you write: "`chcp 1250` already solved the problem". lib2d **is** incompatible with Python 3.5 and thus with the VS 2015 so I couldn't see that `pip3.5 install numpy` on **CP1250** works fine. LOL – Aven Dec 27 '15 at 00:15

1 Answers1

0

You have to use "pip3.5" (if exists or maybe only "pip3"), installer instead of "pip".

"Pip" executes python2.x interpreter, which does NOT support UTF-8 encoding and that's why you are getting UnicodeDecodeError.

Yaaaaaaaaaaay
  • 476
  • 3
  • 9
  • Thanks, your answer summed up with Terry Jan Reedy comments under my question led me to the solution and showed me what I overlooked. Active code page 1250 set by `chcp 1250` and `pip3.5 install ` when package is compatible with _python version_ runs like a dream :) – Aven Dec 27 '15 at 00:29