compose: Unknown encoding error in Windows with cp65001
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
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Reactions: 33
- Comments: 37
I was able to fix it by adding this line to my Powershell profile: source forum post
[Console]::OutputEncoding = [System.Text.Encoding]::Default
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’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?
See if my blog post here leads you in the right direction. https://killerspaz.wordpress.com/2017/03/30/docker-outside-of-docker/
For VSCode run following
[Console]::OutputEncoding = [System.Text.Encoding]::Default
in console to fix.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.
If using ConEmu, I found removing
chcp utf-8
fromStartup > Environment
seemed to do the trick for removing the warning, and doesn’t appear to be messing with any unicode characters.Since updating docker today I have not been able to run docker-compose.
This solution worked for me.
I rebooted my computer and the problem was fixed.
Workaround in steps:
cmd
(no, really don’t use anything else - cmder, conemu, anything)chcp
chcp [number]
(e.g.chcp 852
) in the shell that does not workCmder specific workaround if you don’t want to change behaviour of all of your consoles:
+
buttondocker
for example/icon "%CMDER_ROOT%\cmder.exe"
cmd /k "%ConEmuDir%\..\init.bat" -new_console
)&& chcp [number]
(in my case&& chcp 852
) to the end of each line that has a commandCould we solve this with using docker stack instead of docker-compose?
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.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
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]
.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 ranchcp.com
from the shell even before i added it to my environment.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 !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.
The supposed workaround, of running
chcp 850
orchcp 437
has a terrible side effect: it starts messing up characters.Example:
I need cp65001, and I need docker-compose. There needs to be a better 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.
@tomasfejfar Are you saying to run
docker-compose
in nothing other thancmd.exe
?@tomasfejfar virtual cookie for you! That fixed my problem.