Fundamentals 4 min read

How to Fix Chinese Garbled Text in Jupyter and VS Code: Simple Encoding Tricks

This article explains why Chinese characters appear as garbled text in Jupyter notebooks and VS Code, demonstrates the issue with screenshots, evaluates several Python code fixes, and ultimately provides a reliable solution by setting the console code page to UTF‑8.

Python Crawling & Data Mining
Python Crawling & Data Mining
Python Crawling & Data Mining
How to Fix Chinese Garbled Text in Jupyter and VS Code: Simple Encoding Tricks

1. Introduction

The author encountered a Chinese‑character garbling problem when running code in a Jupyter notebook and sought help in a Python community.

2. Problem Demonstration

Both screenshots below show the garbled output where Chinese text appears as unreadable symbols.

3. Solutions

Solution for Python 2.x – resetting the default encoding to UTF‑8:

import sys
stdi, stdo, stde = sys.stdin, sys.stdout, sys.stderr
reload(sys)
sys.setdefaultencoding('utf-8')
sys.stdin, sys.stdout, sys.stderr = stdi, stdo, stde

This method works only under Python 2 and may still cause issues.

Attempt for Python 3.x – reloading the sys module:

import importlib, sys
importlib.reload(sys)

The above did not resolve the garbling.

A blog post about VS Code Chinese‑character issues ( link ) highlighted the error “锟斤铐”. The effective fix is to set the console code page to UTF‑8 before launching Python:

chcp 65001

Explanation of the “锟斤铐” gibberish: it occurs when text encoded in UTF‑8 is mistakenly read as GBK (or vice‑versa), leading to mis‑interpreted byte sequences.

4. Conclusion

The article walks through the garbled‑character issue, evaluates several code‑based attempts, and identifies the reliable “chcp 65001” workaround for VS Code, helping readers resolve similar encoding problems.

PythonUnicodeVS CodeJupyterChinese characters
Python Crawling & Data Mining
Written by

Python Crawling & Data Mining

Life's short, I code in Python. This channel shares Python web crawling, data mining, analysis, processing, visualization, automated testing, DevOps, big data, AI, cloud computing, machine learning tools, resources, news, technical articles, tutorial videos and learning materials. Join us!

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.