Compose: Unknown encoding error in Windows with cp65001

Created on 28 Jan 2016  ·  37Comments  ·  Source: docker/compose

docker-compose raise an error under PowerShell or cmd with code page 65001(UTF-8):

PS> chcp
Active code page: 65001
PS> docker-compose --version
Traceback (most recent call last):
  File "<string>", line 3, in <module>
  File "C:\projects\compose\compose\cli\main.py", line 54, in main
  File "C:\projects\compose\compose\cli\docopt_command.py", line 23, in sys_dispatch
  File "C:\projects\compose\compose\cli\docopt_command.py", line 26, in dispatch
  File "C:\projects\compose\compose\cli\docopt_command.py", line 29, in parse
  File "C:\projects\compose\compose\cli\docopt_command.py", line 13, in docopt_full_help
  File "c:\projects\compose\venv\lib\site-packages\docopt.py", line 575, in docopt
  File "c:\projects\compose\venv\lib\site-packages\docopt.py", line 484, in extras
LookupError: unknown encoding: cp65001
docker-compose returned -1

$Env:PYTHONIOENCODING = 'utf-8' is no effect.

It works fine with cp932(Shift-JIS, Japanese default code page):

PS> chcp 932
現在のコード ページ: 932
PS> docker-compose --version
docker-compose version 1.6.0rc2, build a7636be
grouwindows-client kinbug

Most helpful comment

I was able to fix it by adding this line to my Powershell profile: source forum post
[Console]::OutputEncoding = [System.Text.Encoding]::Default

All 37 comments

I'm guessing the python we use to build the binary doesn't have this encoding installed. Is it a common encoding? Why isn't it utf-8 ?

cp65001 is encoding for displaying utf-8 in Windows terminal.

List of code page is here:
https://msdn.microsoft.com/en-us/library/windows/desktop/dd317756(v=vs.85).aspx

Python 3.3 seems support cp65001 codec:
https://bugs.python.org/issue13216

And improved in Python 3.5:
https://bugs.python.org/issue20574

I ran into a variant of this, with chcp showing codepage 437 but python detecting cp65001 somehow. docker-compose works in another shell window, so I guess this is somehow environment-specific.

 $ chcp
Active code page: 437
wx-sample feature/VSP-1582-selenium-tests-to-docker* $ docker-compose --version
Traceback (most recent call last):
  File "<string>", line 3, in <module>
  File "C:\projects\compose\compose\cli\main.py", line 54, in main
  File "C:\projects\compose\compose\cli\docopt_command.py", line 23, in sys_dispatch
  File "C:\projects\compose\compose\cli\docopt_command.py", line 26, in dispatch
  File "C:\projects\compose\compose\cli\docopt_command.py", line 29, in parse
  File "C:\projects\compose\compose\cli\docopt_command.py", line 13, in docopt_full_help
  File "c:\projects\compose\venv\lib\site-packages\docopt.py", line 575, in docopt
  File "c:\projects\compose\venv\lib\site-packages\docopt.py", line 484, in extras
LookupError: unknown encoding: cp65001
docker-compose returned -1

I'm using Cmder (Conemu mod) which sets cp65001 by default in the environment variables.

Is there a workaround here we can use for now? What are the implications of changing it?

use powershell

PS C:\Users\insekticid> docker-compose --version
docker-compose version 1.8.0, build d988a55

The same error in PS too.

PS C:\Users\Roma> docker-compose --version
Traceback (most recent call last):
  File "<string>", line 3, in <module>
  File "compose\cli\main.py", line 58, in main
  File "compose\cli\main.py", line 89, in dispatch
  File "compose\cli\docopt_command.py", line 25, in parse
  File "compose\cli\docopt_command.py", line 12, in docopt_full_help
  File "site-packages\docopt.py", line 575, in docopt
  File "site-packages\docopt.py", line 484, in extras
LookupError: unknown encoding: cp65001
docker-compose returned -1

But runs under Cygwin:

Roma@roma-desktop /cygdrive/c/Users/Roma
$ docker-compose --version
docker-compose version 1.8.0, build d988a55

As a workaround, it works with ConsoleZ.

I was able to fix it by adding this line to my Powershell profile: source forum post
[Console]::OutputEncoding = [System.Text.Encoding]::Default

If using ConEmu, I found removing chcp utf-8 from Startup > Environment seemed to do the trick for removing the warning, and doesn't appear to be messing with any unicode characters.

This issue is not happening on Python 3.5 so it may be a good reason to start bundling this with Py3 instead of Py2?

I also get these errors when executing docker tools from FAKE build scripts.

I found in ConEmu using mysis gitbash on Windows 10 i needed to add chcp.com 437 to my ConEmu Startup > Environment to get rid of the python debug info. It's worth noting that 437 is the output i got when i ran chcp.com from the shell even before i added it to my environment.

I get this error when using the PowerShell Integrated Console in VS Code as well.

Works fine in a regular PowerShell window on the same machine.

This error occurs with the combination of Windows10 and the Quick Start Terminal without changing the code page to another one (e.g. 932) by running chcp.com [code page].

$ docker-compose version
docker-compose version 1.12.0, build ee0f34e1
docker-py version: 2.2.1
CPython version: 2.7.13
OpenSSL version: OpenSSL 1.0.2j  26 Sep 2016

$ docker version
Client:
 Version:      17.04.0-ce
 API version:  1.28
 Go version:   go1.7.5
 Git commit:   4845c56
 Built:        Wed Apr  5 23:33:17 2017
 OS/Arch:      windows/amd64

Server:
 Version:      17.04.0-ce
 API version:  1.28 (minimum version 1.12)
 Go version:   go1.7.5
 Git commit:   4845c56
 Built:        Wed Apr  5 18:45:47 2017
 OS/Arch:      linux/amd64
 Experimental: false

Workaround in steps:

  • Start -> Run -> cmd (no, really don't use anything else - cmder, conemu, anything)
  • run chcp
  • copy the currently active code page (for example for Czech it's 852)
  • run chcp [number] (e.g. chcp 852) in the shell that does not work

Cmder specific workaround if you don't want to change behaviour of all of your consoles:

  • in Setings -> Tasks click the + button
  • name the new task docker for example
  • copy values from your preffered task

    • in my case:



      • Task parameters: /icon "%CMDER_ROOT%\cmder.exe"


      • Commands: cmd /k "%ConEmuDir%\..\init.bat" -new_console)



  • to the "Commands" textarea add && chcp [number] (in my case && chcp 852) to the end of each line that has a command

    • in my case there is only one line, but generally there can be more of them

  • open that console (by selecting in the drop down in the new console dialog) and use it for anything docker-related

@tomasfejfar virtual cookie for you! That fixed my problem.

@tomasfejfar Are you saying to run docker-compose in nothing other than cmd.exe?

I had opened an issue about this here as well: https://github.com/PowerShell/PowerShell/issues/3819

I try to use PS in general. But because I'm on windows I have several terminals...

@412andrewmortimer no, you only need "clean" and "plain" cmd.exe to get the default value of code page. You can then run docker-compose anywhere you like

For VSCode run following [Console]::OutputEncoding = [System.Text.Encoding]::Default in console to fix.

On Windows, this error occurs when console's code page is 65001(UTF). For powershell, I change that to 936(Chinese) and it is solved. But for WSL, I can't change the code page, so I'm out of luck here. Hope the upgrading to Py3 happens soon.

The supposed workaround, of running chcp 850 or chcp 437 has a terrible side effect: it starts messing up characters.

Example:

11:58:02 ~$ cmd.exe /c chcp 437 > /tmp/chcp 2>&1
11:58:06 ~$ sudo find / -iname "pkg.?config"
find: ΓÇÿ/mnt/c/$Recycle.Bin/S-1-5-18ΓÇÖ: Permission denied

11:58:12 ~$ cmd.exe /c chcp 65001 > /tmp/chcp 2>&1
11:58:19 ~$ sudo find / -iname "pkg.?config"
find: ‘/mnt/c/$Recycle.Bin/S-1-5-18’: Permission denied

11:58:23 ~$ docker-compose stop
Traceback (most recent call last):
  File "logging\__init__.py", line 872, in emit
LookupError: unknown encoding: cp65001
Logged from file main.py, line 74

I need cp65001, and I need docker-compose. There needs to be a better fix.

See if my blog post here leads you in the right direction. https://killerspaz.wordpress.com/2017/03/30/docker-outside-of-docker/

@killerspaz your post doesn't appear to be anything to do with encoding or codepages.

Ah that's weird, I replied to an email with that asking how to get docker inside a container. It won't let me delete it on my phone, will check when I'm back at a computer.

This issue just started for me after updating Docker via the auto updater for Windows 10.

$ docker-compose --version
Traceback (most recent call last):
  File "docker-compose", line 3, in <module>
  File "compose\cli\main.py", line 67, in main
  File "compose\cli\main.py", line 99, in dispatch
  File "compose\cli\docopt_command.py", line 25, in parse
  File "compose\cli\docopt_command.py", line 12, in docopt_full_help
  File "site-packages\docopt.py", line 575, in docopt
  File "site-packages\docopt.py", line 484, in extras
  File "site-packages\colorama\ansitowin32.py", line 40, in write
  File "site-packages\colorama\ansitowin32.py", line 141, in write
  File "site-packages\colorama\ansitowin32.py", line 169, in write_and_convert
  File "site-packages\colorama\ansitowin32.py", line 174, in write_plain_text
LookupError: unknown encoding: cp65001
Failed to execute script docker-compose

I'm running Version 17.06.1-ce-win24 (13025)

This issue will be fixed (for all use cases, like from inside WSL) once docker-compose is released with embedded Python3 as an option: https://github.com/docker/compose/issues/5063

I rebooted my computer and the problem was fixed.

Had the issue when running from Terminal in VS Code.
Running from Powershell Console - no problem.

Could we solve this with using docker stack instead of docker-compose?

This seems to be happening for a lot of people with the latest creators update to Windows 10.

Is there any way we can resolve this?

The workaround propose by @tomasfejfar https://github.com/docker/compose/issues/2775#issuecomment-306245783
Do seems to works for powershell but not for vs code.

I can also confirm that the error affected me in native powershell too.
docker-compose colorama bug

I also confirmed that this problem exists/surfaces using vscode on a Windows machine when there are comments in the docker-compose file. I got a workaround which did the trick for me docker-compose pull | % ToString on my Powershell prompt within vscode. Thanks @mklement0 !

I was able to 'resolve' this issue with a workaround, using the win-unicode-console package for Python with pip install win-unicode-console and then restarting the terminal application.

Since updating docker today I have not been able to run docker-compose.

$ docker --version
Docker version 19.03.5, build 633a0ea

I found in ConEmu using mysis gitbash on Windows 10 i needed to add chcp.com 437 to my ConEmu Startup > Environment to get rid of the python debug info. It's worth noting that 437 is the output i got when i ran chcp.com from the shell even before i added it to my environment.

This solution worked for me.

Think i upgraded my powershell recently, forgot i had something like :

# $OutputEncoding = [console]::InputEncoding = [console]::OutputEncoding =
#                     New-Object System.Text.UTF8Encoding

in my profile. Removed it and i don't have this problem anymore.

Was this page helpful?
0 / 5 - 0 ratings