Skip to content

Instantly share code, notes, and snippets.

@Jawabiscuit
Last active August 23, 2017 00:27
Show Gist options
  • Save Jawabiscuit/c72eaa21237cc762bf01433293502ebf to your computer and use it in GitHub Desktop.
Save Jawabiscuit/c72eaa21237cc762bf01433293502ebf to your computer and use it in GitHub Desktop.
LookupError: unknown encoding: cp65001

solution thread

Cause

conda update anaconda

Symptom

PS C:\Users\Jonas> conda install virtualenv
Traceback (most recent call last):
  File "C:\Anaconda2\lib\logging\__init__.py", line 872, in emit
    stream.write(ufs % msg)
LookupError: unknown encoding: cp65001
Logged from file exceptions.py, line 586
Traceback (most recent call last):
  File "C:\Anaconda2\lib\logging\__init__.py", line 872, in emit
    stream.write(ufs % msg)
LookupError: unknown encoding: cp65001
Logged from file exceptions.py, line 590
Traceback (most recent call last):
  File "C:\Anaconda2\lib\logging\__init__.py", line 872, in emit
    stream.write(ufs % msg)
LookupError: unknown encoding: cp65001
Logged from file exceptions.py, line 591
Traceback (most recent call last):
  File "C:\Anaconda2\lib\logging\__init__.py", line 872, in emit
    stream.write(ufs % msg)
LookupError: unknown encoding: cp65001
Logged from file exceptions.py, line 592
Traceback (most recent call last):
  File "C:\Anaconda2\lib\logging\__init__.py", line 872, in emit
    stream.write(ufs % msg)
LookupError: unknown encoding: cp65001
Logged from file exceptions.py, line 593

Error

LookupError: unknown encoding: cp65001

Check current output encoding

PS> [Console]::OutputEncoding

BodyName          : utf-8
EncodingName      : Unicode (UTF-8)
HeaderName        : utf-8
WebName           : utf-8
WindowsCodePage   : 1200
IsBrowserDisplay  : True
IsBrowserSave     : True
IsMailNewsDisplay : True
IsMailNewsSave    : True
IsSingleByte      : False
EncoderFallback   : System.Text.EncoderReplacementFallback
DecoderFallback   : System.Text.DecoderReplacementFallback
IsReadOnly        : False
CodePage          : 65001

There's the unrecognized CodePage. For me, changing OutputEncoding fixed the issue:

Fix

PS> [Console]::OutputEncoding = [System.Text.Encoding]::Default

IsSingleByte      : True
BodyName          : iso-8859-1
EncodingName      : Western European (Windows)
HeaderName        : Windows-1252
WebName           : Windows-1252
WindowsCodePage   : 1252
IsBrowserDisplay  : True
IsBrowserSave     : True
IsMailNewsDisplay : True
IsMailNewsSave    : True
EncoderFallback   : System.Text.InternalEncoderBestFitFallback
DecoderFallback   : System.Text.InternalDecoderBestFitFallback
IsReadOnly        : False
CodePage          : 1252

Fix 2

add PYTHONIOENCODING as env variable with value UTF-8

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment