Python looks up Error: unknown encoding: cp65001 on Windows

Python got the following error at the command prompt of Windows7

LookupError: unknown encoding: cp65001

This is because the character code of the command prompt, cp65001, is unknown to python.

Correspondence in case of own program

If it was your own program

import sys
import codecs
def cp65001(name):
    if name.lower() == 'cp65001':
        return codecs.lookup('utf-8')
codecs.register(cp65001)

You can write it like this and define cp65001 as utf-8.

Correspondence for python tools such as pip

The above method cannot be used with python tools such as pip. For example, if this comes out with pip install etc.

If you say so, set the environment variable

PYTHONIOENCODING=utf-8

You can give it as.

Recommended Posts

Python looks up Error: unknown encoding: cp65001 on Windows
Python on Windows
python basic on windows ②
Install python on windows
Set-enable Python virtualenv on Windows
Set up Python 3.4 on Ubuntu
Run Openpose on Python (Windows)
Install watchdog on Windows + Python 3.3
Python + Kivy development on Windows
Sphinx-autobuild (0.5.2) on Windows7, Python 3.5.1, Sphinx 1.3.5
Fastest Python installation on Windows
Build Python environment on Windows
Build python environment on windows
Set up Polyglot on Windows
I ran python on windows
[Python] [Chainer] [Windows] Install Chainer on Windows
Use Python on Windows (PyCharm)
Precautions when opening other than CP932 (Shift-JIS) encoding on Windows
Python environment construction memo on Windows 10
Python 3.6 on Windows ... and to Xamarin.
Installing Kivy on Windows10 64bit Python3.5
Anaconda python environment construction on Windows 10
Install python2.7 on windows 32bit environment
Install xgboost (python version) on Windows
Install Python on Windows + pip + virtualenv
Install Pytorch on Blender 2.90 python on Windows
Integrate Modelica and Python on Windows
Installing Kivy-Designer on Windows10 64bit Python3.5
Set up Python environment on CentOS
Mecab / Cabocha / KNP on Python + Windows
Install Python development environment on Windows 10
Python CGI file created on Windows
Getting started with Python 3.8 on Windows
Reproduce One-Touch Search on Python 3.7.3. (Windows 10)
Notes for using OpenCV on Windows10 Python 3.8.3.
Run servo with Python on ESP32 (Windows)
Python 2.7, 3.4, 3.5 extension module build environment on Windows
Virtualenv does not work on Python3.5 (Windows)
Creating a python virtual environment on Windows
Use without installing python 2.x on Windows
windows7 / python3.3 / virtualenv / cx_Freeze / Import Error / MAXREPEAT
Python encoding
Install and run Python3.5 + NumPy + SciPy on Windows 10
Put MicroPython on Windows to run ESP32 on Python
Install Python3, numpy, pandas, matplotlib, etc. on Windows
(Windows) Causes and workarounds for UnicodeEncodeError on Python 3
Simply build a Python 3 execution environment on Windows
Notes on installing Python3 and using pip on Windows7
Install OpenCV 4.0 and Python 3.7 on Windows 10 with Anaconda
Note on encoding when LANG = C in Python
Set up python Tornado environment on raspbian jessie
Set up a Python development environment on Marvericks
To write to Error Repoting in Python on GAE
[Python] How to install OpenCV on Anaconda [Windows]
[Note] Installing Python 3.6 + α on Windows and RHEL
Installing TensorFlow on Windows Easy for Python beginners
Eliminates SSL error when PIP Install on Windows.
Create a Python virtual development environment on Windows
Install ZIP version Python and pip on Windows 10